When new users sign up, call the createUser function in order to add
them to the analytics database. You can add a multitude of user attributes
to attach to this user when they sign up. For new registrations, be sure to
set the isNewUser parameter to true so we can add their registration time.
createUser() function
Creates a new user in the analytics database.
Signature:export declare function createUser(user: User, isNewUser: boolean): Promise<void>;
Example:
pjdwsdk.init('<INSERT_API_KEY_HERE>', { host: '<INSERT_HOST_URL_HERE>', ...options });
pjdwsdk.createUser({
"first_name": "John",
"last_name": "Doe",
"phone": "4044044041",
"nationality": "United States",
"secondary_nationality": "n/a",
"residence": "New York",
"phone_country_code": "+1",
"gender": "Male",
"dob": "1996-01-16",
"source": "string",
"address": {
"address_lines": [
"8352 Del Monte Road",
"Syosset",
"NY 11791"
],
"locality": "city",
"admin_area": "New York",
"sub_admin_area": "Albany",
"postal_code": "12084",
"country_code": "US",
"latitude": "48.726696",
"longitude": "-79.684658"
},
"meta": {},
"permissions": {
"marketing": {
"sms_marketing_allowed": true,
"email_marketing_allowed": true,
"mail_marketing_allowed": true,
"call_marketing_allowed": true,
"push_notification_marketing_allowed": true,
"do_not_sell": true
},
"do_not_track": false
},
"membership": {
"is_season_ticket_holder": true,
"is_single_game_ticket_buyer": true,
"is_ticket_package_buyer": true,
"is_club_member": true,
"is_loyalty_program_member": true
}
}).then(function(response){
console.log('response', response);
}, function(error){
console.error("Failure createUser()", error);
});
Parameters
| Parameter | Type | Description |
|---|
| user | User | The user to create |
| isNewUser | boolean | (Optional) This property signals that the user is a newly registered user. If you are simply creating a user because they do not exist in the analytics system yet, you can either leave this empty or pass false. |
Returns:Promise<void>
User interface
Properties
| Property | Type | Description |
|---|
| id | string | The id of the user in your system |
| first_name | string | |
| last_name | string | |
| email? | string | (Optional) |
| phone_country_code? | string | (Optional) |
| phone? | string | (Optional) |
| gender? | string | (Optional) |
| dob? | string | (Optional) |
| address? | Address | (Optional) |
| membership? | Membership | (Optional) |
| meta? | object | (Optional) |
| nationality? | string | (Optional) |
| permissions? | Permissions | (Optional) |
| residence? | string | (Optional) |
| secondary_nationality? | string | (Optional) |
| source? | string | (Optional) |
Address interface
Properties
| Property | Type | Description |
|---|
| address_lines? | [string, string?, string?] | (Optional) |
| admin_area? | string | (Optional) state, province, island, etc. |
| country_code? | string | (Optional) code for country (ex: CA for Canada) |
| latitude? | string | (Optional) |
| locality? | string | (Optional) city, town, village, etc. |
| longitude? | string | (Optional) |
| postal_code | string | postal or zip code |
| sub_admin_area? | string | (Optional) county, other governing entity |
Membership interface
Properties
| Property | Type | Description |
|---|
| is_season_ticket_holder? | boolean | (Optional) |
| is_single_game_ticket_buyer? | boolean | (Optional) |
| is_ticket_package_buyer? | boolean | (Optional) |
| is_club_member? | boolean | (Optional) |
| is_loyalty_program_member? | boolean | (Optional) |
Permissions interface
Properties
| Property | Type | Description |
|---|
| marketing? | MarketingPermission | (Optional) Marketing permission (ex: sms, email, phone, ...) |
| do_not_track? | boolean | (Optional) |
MarketingPermission interface
Properties
| Property | Type | Description |
|---|
| sms_marketing_allowed? | boolean | (Required) sms allowed? |
| email_marketing_allowed? | boolean | (Required) email allowed? |
| mail_marketing_allowed? | boolean | (Required) mail allowed? |
| call_marketing_allowed? | boolean | (Required) call allowed? |
| push_notification_marketing_allowed? | boolean | (Required) push notification allowed? |
| do_not_sell? | boolean | (Required) |
| custom? | object | (Optional) like facebook, twitter |
pjdwsdk.setCookiePermissions({custom: {
facebook_targetted_ads: true
}});