{"_id":"560d6190af9723190093812c","user":"560c92f2ac2859170013faa3","version":{"_id":"560c93ae7e9b9d0d00ca81a5","project":"560c93ad7e9b9d0d00ca81a2","__v":9,"createdAt":"2015-10-01T02:00:14.709Z","releaseDate":"2015-10-01T02:00:14.709Z","categories":["560c93af7e9b9d0d00ca81a6","560c9d9399bb5a0d0044f220","560d76d899bb5a0d0044f307","560d76ee1ec45619006069ed","560d86e099bb5a0d0044f32e","560dba80373c0e0d0024ff3b","57c722ecdf19130e001fba5d","57c743d1b6f94a2200659903","58995ec083f743190077bbe2"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"editedParams2":true,"project":"560c93ad7e9b9d0d00ca81a2","parentDoc":null,"editedParams":true,"__v":2,"category":{"_id":"560c9d9399bb5a0d0044f220","pages":["560ca0517048021700e180e6","560d6190af9723190093812c","560d74751ec45619006069e9","560d769505b3941700338762"],"project":"560c93ad7e9b9d0d00ca81a2","version":"560c93ae7e9b9d0d00ca81a5","__v":4,"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-10-01T02:42:27.154Z","from_sync":false,"order":0,"slug":"javascript-api-client-side","title":"JavaScript API (client-side)"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-10-01T16:38:40.906Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","examples":{"codes":[{"language":"javascript","name":"","code":"Attribution.track(event, [properties], [callback]);"}]},"results":{"codes":[]},"auth":"required","params":[{"_id":"560ca0517048021700e180e9","ref":"","in":"body","required":true,"desc":"The name of the event","default":"","type":"string","name":"event"},{"_id":"560ca0517048021700e180e8","ref":"","in":"body","required":false,"desc":"A hashtable of properties describing the event.","default":"","type":"object","name":"properties"},{"_id":"560ca0517048021700e180e7","ref":"","in":"body","required":false,"desc":"A callback function that gets called after a short timeout.","default":"","type":"object","name":"callback"}],"url":"/Attribution.track(event, [properties], [callback]);"},"isReference":true,"order":1,"body":"We recommend using the user ID field from your database and passing the email address in as a trait, in case a user changes their email address later on. You can pass us as many customer traits as you’d like to save.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Attribution.identify([userId], [traits], [callback]);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"**userId** \\n*String, optional*\",\n    \"0-1\": \"The ID used to identify this user in your database. You can omit this and just record traits if you don’t yet have a database ID.\",\n    \"1-0\": \"**traits** \\n*Object, optional*\",\n    \"1-1\": \"A hashtable of traits describing the user such as name and email.\",\n    \"2-1\": \"A callback function that gets called after a short timeout.\",\n    \"2-0\": \"**callback** \\n*Object, optional*\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Attribution.identify('00812938', { email: 'bob:::at:::initech.co' });\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Special Properties for Identify\"\n}\n[/block]\nAttribution recognizes special properties on the identify call, and displays them on the customer view in the app. Here’s are the special properties and an example of an call with all of them:\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"**email **\\n*String*\",\n    \"1-0\": \"**firstName **\\n*String*\",\n    \"4-1\": \"The user’s full name.\",\n    \"3-1\": \"The user’s last name.\",\n    \"2-1\": \"The user’s unique ID used in your database\",\n    \"1-1\": \"The user’s first name\",\n    \"2-0\": \"**id **\\n*String*\",\n    \"3-0\": \"**lastName **\\n*String*\",\n    \"4-0\": \"**name **\\n*String*\",\n    \"0-1\": \"The user’s email address.\",\n    \"5-0\": \"**createdAt**\\n*Date*\",\n    \"5-1\": \"The date the users account was first created.\",\n    \"6-0\": \"**companyId**\\n*String*\",\n    \"6-1\": \"If the user belongs to company inside your internal data structure you can specify it unique ID of that company. This allows to enable Account Based Marketing (ABM) feature.\"\n  },\n  \"cols\": 2,\n  \"rows\": 7\n}\n[/block]\nIf you want to distinguish between new and existing customers in Attribution you **must** add the createdAt date only once when a new user registers . *createdAt* is expected to be date time (JavaScript date or ISO 8601 time format).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Attribution.identify('00812938', { \\n  email: 'bob@initech.co',\\n  firstName: 'Bob',\\n  id: '00812938', // Note: redundent, just here as example\\n  lastName: 'Slydell',\\n  name: 'Bob Slydell',\\n  createdAt: new Date() // Note: Only do this once or specify exact datetime\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"Identify is used to link a users actions and pageviews to a recognizable name or email address.","slug":"identify","type":"fn","title":"Identify"}

Identify

Identify is used to link a users actions and pageviews to a recognizable name or email address.

We recommend using the user ID field from your database and passing the email address in as a trait, in case a user changes their email address later on. You can pass us as many customer traits as you’d like to save. [block:code] { "codes": [ { "code": "Attribution.identify([userId], [traits], [callback]);", "language": "javascript" } ] } [/block] [block:parameters] { "data": { "0-0": "**userId** \n*String, optional*", "0-1": "The ID used to identify this user in your database. You can omit this and just record traits if you don’t yet have a database ID.", "1-0": "**traits** \n*Object, optional*", "1-1": "A hashtable of traits describing the user such as name and email.", "2-1": "A callback function that gets called after a short timeout.", "2-0": "**callback** \n*Object, optional*" }, "cols": 2, "rows": 3 } [/block] [block:code] { "codes": [ { "code": "Attribution.identify('00812938', { email: 'bob@initech.co' });", "language": "javascript" } ] } [/block] [block:api-header] { "type": "basic", "title": "Special Properties for Identify" } [/block] Attribution recognizes special properties on the identify call, and displays them on the customer view in the app. Here’s are the special properties and an example of an call with all of them: [block:parameters] { "data": { "0-0": "**email **\n*String*", "1-0": "**firstName **\n*String*", "4-1": "The user’s full name.", "3-1": "The user’s last name.", "2-1": "The user’s unique ID used in your database", "1-1": "The user’s first name", "2-0": "**id **\n*String*", "3-0": "**lastName **\n*String*", "4-0": "**name **\n*String*", "0-1": "The user’s email address.", "5-0": "**createdAt**\n*Date*", "5-1": "The date the users account was first created.", "6-0": "**companyId**\n*String*", "6-1": "If the user belongs to company inside your internal data structure you can specify it unique ID of that company. This allows to enable Account Based Marketing (ABM) feature." }, "cols": 2, "rows": 7 } [/block] If you want to distinguish between new and existing customers in Attribution you **must** add the createdAt date only once when a new user registers . *createdAt* is expected to be date time (JavaScript date or ISO 8601 time format). [block:code] { "codes": [ { "code": "Attribution.identify('00812938', { \n email: 'bob@initech.co',\n firstName: 'Bob',\n id: '00812938', // Note: redundent, just here as example\n lastName: 'Slydell',\n name: 'Bob Slydell',\n createdAt: new Date() // Note: Only do this once or specify exact datetime\n});", "language": "javascript" } ] } [/block]