{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","settings":"","results":{"codes":[]},"params":[]},"next":{"description":"","pages":[]},"title":"Identify","type":"fn","slug":"identify","excerpt":"Identifies the current user with their `user_id` or `email`.","body":"[block:callout]\n{\n  \"type\": \"danger\",\n  \"body\": \"This page documents a no-longer supported version of the Boomtrain JavaScript Library (versions 4.x and below). The new `p13n.js` library, documented [here](https://boomtrain.readme.io/v1/docs/p13njs-getting-started) is the currently supported library for integrating with ZetaHub.\",\n  \"title\": \"Deprecated API Warning\"\n}\n[/block]\nIf your website uses authentication or another form of client-side identification and you therefore know who is browsing, call `identify` with this user's unique identifier on login or upon start of the identified session. When called, `analyticstrain` library will store this identity in the user's browser to ensure that any subsequent behavior is tracked using that identity.\n\nIn addition, we will merge any anonymous browsing history from this browser into the identified user profile.\n\nIf a different _identified_ user was browsing at the time this function is called, the new identity passed into this function will supersede the previous identity, and the newly logged-in user's identity will be used for subsequent behavioral tracking in this browser.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"_bt.identify(identifier, [callback]);\",\n      \"language\": \"javascript\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\nThe `identify` call has the following fields:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Field\",\n    \"0-0\": \"`identifier`\",\n    \"1-0\": \"`callback` *optional*\",\n    \"1-1\": \"Function\",\n    \"1-2\": \"A function that is executed after this function completes and the browser is now identified according to the identifier.\",\n    \"h-2\": \"Description\",\n    \"0-1\": \"Object\",\n    \"0-2\": \"An identifier for this new user, either a `user_id` or an `email` address. This value must be a case-insensitive unique identifier for your user. See Identifier Format below for details.\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\nNote that if at any time the user logs out, the [Clear](https://boomtrain.readme.io/v1/docs/clear) function should be called to ensure that the browser is no longer associated with this identified user.\n[block:api-header]\n{\n  \"title\": \"Identifier Format\"\n}\n[/block]\nThe `identify` function allows you to identify a user with either a unique user ID or an email address. These must be specified exactly as either a `user_id` or an `email` property of the object, and only one of these two may be specified. When an `email` is specified, this email will be added to the `contacts` field for this user in the Boomtrain Marketing Engine.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"_bt.identify(\\n  {'user_id':'example_user'}, \\n);\",\n      \"language\": \"javascript\",\n      \"name\": \"Sample Identify with User ID\"\n    },\n    {\n      \"code\": \"_bt.identify(\\n\\t{'email':'example:::at:::user.com'}\\n);\",\n      \"language\": \"javascript\",\n      \"name\": \"Sample Identify with Email Address\"\n    }\n  ]\n}\n[/block]","updates":[],"order":1,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5928929c94d9382f0096d975","parentDoc":null,"__v":0,"createdAt":"2017-05-26T20:39:56.294Z","user":"566887ff8639090d00759415","project":"56aff08c3a5b810d00745d99","version":{"version":"1","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["56aff08d3a5b810d00745d9d","56aff24f3a5b810d00745da0","56aff25dbc304a0d00ace207","56aff287e0b1e40d00c53798","56aff2b260a37a0d00ed8883","56aff2b8e0b1e40d00c53799","56aff2bd5b1f01170014dc7b","56aff2c9d21e9c0d00b62993","56aff493aef9a21700da0e67","56aff4ce1486990d009c0f64","56aff4da5b1f01170014dc7d","56aff4dfe0b1e40d00c537a2","56aff4e59d32e30d0006d3e9","56aff4e91486990d009c0f65","56aff4f93a5b810d00745da2","56aff4fe9d32e30d0006d3ea","56b91c7ab1e03e0d001057c5","56c4f51aba4a540d0091b9a2","56cd09488c4a331d002c1e44","56d4ec4773dcd20b00fb8769","56e79bc515f96b2200878e54","56ec25c538ff1d2200d56cc2","56ec3a6f36bc8e0e00f190c8","56ec3e308ea7ce0e00a3d8b0","5724d8fe4255580e005938b2","5724dc842ad0bc1700122803","5776ef2a04f7500e0095dc37","57ab9f70b5e8742000e17eb9","57d7117646dcc30e007dd21f","58e6abd5b1eece19008b7d31","59288c65e2653627003e1221","5a8f4797a44f8600128e75ee","5bbf8833eb416300039a2c14","5ea811617bf4b5007328a0af"],"_id":"56aff08c3a5b810d00745d9c","project":"56aff08c3a5b810d00745d99","releaseDate":"2016-02-01T23:55:56.544Z","__v":34,"createdAt":"2016-02-01T23:55:56.544Z"},"category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Zeta JavaScript Library (versions 4.x and lower)","slug":"boomtrain-javascript-sdk","order":4,"from_sync":false,"reference":false,"_id":"59288c65e2653627003e1221","createdAt":"2017-05-26T20:13:25.882Z","project":"56aff08c3a5b810d00745d99","version":"56aff08c3a5b810d00745d9c","__v":0},"githubsync":""}

Identify

Identifies the current user with their `user_id` or `email`.

[block:callout] { "type": "danger", "body": "This page documents a no-longer supported version of the Boomtrain JavaScript Library (versions 4.x and below). The new `p13n.js` library, documented [here](https://boomtrain.readme.io/v1/docs/p13njs-getting-started) is the currently supported library for integrating with ZetaHub.", "title": "Deprecated API Warning" } [/block] If your website uses authentication or another form of client-side identification and you therefore know who is browsing, call `identify` with this user's unique identifier on login or upon start of the identified session. When called, `analyticstrain` library will store this identity in the user's browser to ensure that any subsequent behavior is tracked using that identity. In addition, we will merge any anonymous browsing history from this browser into the identified user profile. If a different _identified_ user was browsing at the time this function is called, the new identity passed into this function will supersede the previous identity, and the newly logged-in user's identity will be used for subsequent behavioral tracking in this browser. [block:code] { "codes": [ { "code": "_bt.identify(identifier, [callback]);", "language": "javascript", "name": null } ] } [/block] The `identify` call has the following fields: [block:parameters] { "data": { "h-0": "Field", "0-0": "`identifier`", "1-0": "`callback` *optional*", "1-1": "Function", "1-2": "A function that is executed after this function completes and the browser is now identified according to the identifier.", "h-2": "Description", "0-1": "Object", "0-2": "An identifier for this new user, either a `user_id` or an `email` address. This value must be a case-insensitive unique identifier for your user. See Identifier Format below for details." }, "cols": 3, "rows": 2 } [/block] Note that if at any time the user logs out, the [Clear](https://boomtrain.readme.io/v1/docs/clear) function should be called to ensure that the browser is no longer associated with this identified user. [block:api-header] { "title": "Identifier Format" } [/block] The `identify` function allows you to identify a user with either a unique user ID or an email address. These must be specified exactly as either a `user_id` or an `email` property of the object, and only one of these two may be specified. When an `email` is specified, this email will be added to the `contacts` field for this user in the Boomtrain Marketing Engine. [block:code] { "codes": [ { "code": "_bt.identify(\n {'user_id':'example_user'}, \n);", "language": "javascript", "name": "Sample Identify with User ID" }, { "code": "_bt.identify(\n\t{'email':'[email protected]'}\n);", "language": "javascript", "name": "Sample Identify with Email Address" } ] } [/block]