{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","results":{"codes":[]},"settings":"","params":[]},"next":{"description":"","pages":[]},"title":"Set User Attributes","type":"fn","slug":"set","excerpt":"Set attributes for the current user","body":"[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Deprecated API Warning\",\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}\n[/block]\nSets or updates attributes for the currently-identified user. Note that this call will fail if the current user does not have a known `user_id` or `email` already, as provided in the [Signup](doc:signup) or [Identify](doc:identify) routes. You may also specify a `user_id` or `email` as a property of this call itself.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"_bt.person.set(attributes, [callback]);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThe `set` call has the following fields:\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`attributes`\",\n    \"h-2\": \"Description\",\n    \"h-1\": \"\",\n    \"h-0\": \"Field\",\n    \"0-1\": \"Object\",\n    \"0-2\": \"An object containing key:value pairs indicating attributes to be set on this user. See Attributes Format below for more information.\",\n    \"1-0\": \"`callback` *optional*\",\n    \"1-2\": \"A function that is executed after this function completes and the attributes have been set for the user.\",\n    \"1-1\": \"Function\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"_bt.person.set({\\n  'first_name': 'Michael',\\n  'last_name': 'Bluth',\\n  'signed_up_at': '2003-11-02T09:00:00+08:00',\\n  'newsletter': true,\\n  'favorite_things': ['hard work', 'george michael', 'candy beans']\\n  'title': 'CEO',\\n  'company': 'The Bluth Company'\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Attributes Format\"\n}\n[/block]\nAttributes can be provided to be set as user attributes on the current user. These attributes will be attached to the user's profile in the Boomtrain Marketing Engine.\n\nWhile attributes can have any form, the following attributes are reserved and specially-handled by Boomtrain:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Attribute\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`first_name`\",\n    \"1-0\": \"`last_name`\",\n    \"2-0\": \"`signed_up_at`\",\n    \"0-1\": \"String\",\n    \"0-2\": \"First name of the user.\",\n    \"1-1\": \"String\",\n    \"1-2\": \"Last name of the user.\",\n    \"2-1\": \"ISO-8601 Timestamp String\",\n    \"2-2\": \"Time at which this user first signed up.\",\n    \"3-0\": \"`user_id`\",\n    \"3-1\": \"String\",\n    \"3-2\": \"The `user_id` of this user. When provided, this will identify the user just as it does in the [Identify](doc:identify) call. Note that this will change the identity of the current user to the provided `user_id` and set the attributes for this provided user.\",\n    \"4-0\": \"`email`\",\n    \"4-1\": \"String\",\n    \"4-2\": \"The `email` of this user. When provided, this will identify the user just as it does in the [Identify](doc:identify) call. Note that this will change the identity of the current user to the provided `email` and set the attributes for this provided user.\"\n  },\n  \"cols\": 3,\n  \"rows\": 5\n}\n[/block]","updates":[],"order":5,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5928b339e2653627003e1a7e","user":"566887ff8639090d00759415","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},"project":"56aff08c3a5b810d00745d99","__v":0,"createdAt":"2017-05-26T22:59:05.102Z","githubsync":"","parentDoc":null}

Set User Attributes

Set attributes for the current user

[block:callout] { "type": "danger", "title": "Deprecated API Warning", "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." } [/block] Sets or updates attributes for the currently-identified user. Note that this call will fail if the current user does not have a known `user_id` or `email` already, as provided in the [Signup](doc:signup) or [Identify](doc:identify) routes. You may also specify a `user_id` or `email` as a property of this call itself. [block:code] { "codes": [ { "code": "_bt.person.set(attributes, [callback]);", "language": "javascript" } ] } [/block] The `set` call has the following fields: [block:parameters] { "data": { "0-0": "`attributes`", "h-2": "Description", "h-1": "", "h-0": "Field", "0-1": "Object", "0-2": "An object containing key:value pairs indicating attributes to be set on this user. See Attributes Format below for more information.", "1-0": "`callback` *optional*", "1-2": "A function that is executed after this function completes and the attributes have been set for the user.", "1-1": "Function" }, "cols": 3, "rows": 2 } [/block] [block:code] { "codes": [ { "code": "_bt.person.set({\n 'first_name': 'Michael',\n 'last_name': 'Bluth',\n 'signed_up_at': '2003-11-02T09:00:00+08:00',\n 'newsletter': true,\n 'favorite_things': ['hard work', 'george michael', 'candy beans']\n 'title': 'CEO',\n 'company': 'The Bluth Company'\n});", "language": "javascript", "name": "Example" } ] } [/block] [block:api-header] { "title": "Attributes Format" } [/block] Attributes can be provided to be set as user attributes on the current user. These attributes will be attached to the user's profile in the Boomtrain Marketing Engine. While attributes can have any form, the following attributes are reserved and specially-handled by Boomtrain: [block:parameters] { "data": { "h-0": "Attribute", "h-2": "Description", "0-0": "`first_name`", "1-0": "`last_name`", "2-0": "`signed_up_at`", "0-1": "String", "0-2": "First name of the user.", "1-1": "String", "1-2": "Last name of the user.", "2-1": "ISO-8601 Timestamp String", "2-2": "Time at which this user first signed up.", "3-0": "`user_id`", "3-1": "String", "3-2": "The `user_id` of this user. When provided, this will identify the user just as it does in the [Identify](doc:identify) call. Note that this will change the identity of the current user to the provided `user_id` and set the attributes for this provided user.", "4-0": "`email`", "4-1": "String", "4-2": "The `email` of this user. When provided, this will identify the user just as it does in the [Identify](doc:identify) call. Note that this will change the identity of the current user to the provided `email` and set the attributes for this provided user." }, "cols": 3, "rows": 5 } [/block]