You can easily update already existing contact’s data and add a new one using JavaScript.
To update the contact’s data in the Contact List or to create a new one, you need to properly identify your user and fire an event on your web page.
IMPORTANT
Include those snippets on every page in your app, immediately before the closing </body>
tag to initialize JS API and identify your user.
Connecting the library:
<script type="text/javascript" src="//js.smartsender.io/js/v1/JS_SCRIPT_ID.js> </script>
Contact identificator:
<script type="text/javascript"> var contact = new_smartSenderContact('{{identifier}}'); </script>
Step-by-step instructions:
- Install JS API
- Create and generate a JS code snippet.
- Call JS API methods to manage your user data:
- To add a new user to the Contact List see example:
<script type="text/javascript"> contact.Add({ name: "John Doe", email: "user@example.com", phoneNumber: "+15555555", userId: "myUserId", active: true, emailSubscribe: true, smsSubscribe: true, firstName: "John", lastName: "Doe", contactBirthday: "1990-01-01", contactLanguage: "en", contactGender: "female", contactTimezone: "Europe/Tallinn", contactScore: 100, avatarLink: "img.smartsender.io/g/06c38b4568.jpg", facebookLink: "https://www.facebook.com/smartsender.io", instagramLink: "instagram.com/smartsender", linkedInLink: "linkedin.com/company/smartsender" twitterLink: "twitter.com/smart_sender", tiktokLink: "tiktok.com/smartsender", sourceId: "Source_ID_from_SmartSender", customerSourceId: "Customer_Source_ID_From_Your_Platform", cac: { value: 2.05, currency: "USD", }, variables: [ {name: "stringVariableName", value: "newVariableValue"}, {name: "dateVariableName", value: "2020-10-20"} ], }); </script>
Parameters contact 'required'
An array of contact information. name 'optional'
The optional display name to use for the recipient email 'optional'
Contact’s email address. phoneNumber 'optional'
IMPORTANT:
should bevalid E.164 phone number
format.userId 'optional'
Contact’s unique user ID from your platform to enable management of the contact in the list based on it. active 'optional'
You can set if the contact is enable contact list or not. The default value is false (disable). true 'optional'
Contact enabled. Contact can receive communication from enabled channels. false 'default'
Contact disabled. No communications will be send to this contact. emailSubscribe 'optional'
You can set if the contact is subscribed to receiving emails or not. The default value is false (unsubscribed). true 'optional'
Subscribe contact to emails false 'default'
Unsubscribe contact from emails smsSubscribe 'optional'
You can set if the contact is subscribed to receiving SMS or not. The default value is false (unsubscribed). true 'optional'
Subscribe contact to SMS false 'default'
Unsubscribe contact from SMS firstName 'optional'
Contact’s first name lastName 'optional'
Contact’s last name contactBirthday 'optional'
Contact’s birth date in ENUM_DATE
(YYYY-MM-DD) formatcontactLanguage 'optional'
Contact’s locale in ISO 639-1
formatcontactGender 'optional'
Contact’s gender in ISO/IEC 5218
format0 Not known 1 Male 2 Female 9 Not applicable contactTimezone 'optional'
Contact’s timezone in ISO 8601
formatcontactScore 'optional'
Contact Score avatarLink 'optional'
Link to contact’s avatar image. facebookLink 'optional'
Link to contact’s Facebook profile. instagramLink 'optional'
Link to contact’s Instagram profile. linkedInLink 'optional'
Link to contact’s LinkedIn profile. twitterLink 'optional'
Link to contact’s Twitter profile. tiktokLink 'optional'
Link to contact’s TikTok profile. variables 'optional'
An array of contact variables and their values. name 'required'
Variable name in lowerCamelCase format WARNING:
Please use only latinlowerCamelCase
format. No numbers or other symbols allowed.value 'required'
Variable value in 'ENUM_STRING'
or'ENUM_DATE'
(YYYY-MM-DD) format correspondinglysourceId 'optional'
Contact’s unique source ID from SmartSender platform customerSourceId 'optional'
Contact’s unique source ID from your system to synchronize two sides cac 'optional'
value 'required'
CAC value in 'ENUM_STRING'
format correspondinglycurrency 'required'
(EUR, USD) WARNING:
Please use only latin uppercase format. No numbers or other symbols allowed.
- To update contact data in the Contact List see example:
<script type="text/javascript"> contact.update({ name: "John Doe", email: "user@example.com", phoneNumber: "+15555555", userId: "myUserId", active: true, emailSubscribe: true, smsSubscribe: true, desktopWebPushSubscribe: true, mobileWebPushSubscribe: true, telegramSubscribe: true, firstName: "John", lastName: "Doe", contactBirthday: "1990-01-01", contactLanguage: "en", contactGender: "female", contactTimezone: "Europe/Tallinn", contactScore: 100, avatarLink: "img.smartsender.io/g/06c38b4568.jpg", facebookLink: "https://www.facebook.com/smartsender.io", instagramLink: "instagram.com/smartsender", linkedInLink: "linkedin.com/company/smartsender" twitterLink: "twitter.com/smart_sender", tiktokLink: "tiktok.com/smartsender", sourceId: "Source_ID_from_SmartSender", customerSourceId: "Customer_Source_ID_From_Your_Platform", cac: { value: 2.05, currency: "USD", }, variables: [ {name: "stringVariableName", value: "newVariableValue"}, {name: "dateVariableName", value: "2020-10-20"} ], }); </script>
Parameters contact
'required'
An array of contact information want to update. name
'optional'
The optional display name to use for the recipient email
'optional'
Contact’s email address. phoneNumber
'optional'
IMPORTANT
should bevalid E.164 phone number
format.userId
'optional'
Contact’s unique user ID from your platform to enable management of the contact in the list based on it. active
'optional'
You can set if the contact is enable contact list or not.
The default value is false (disable).true
'optional'
Contact enabled. Contact can receive communication from enabled channels. false
'default'
Contact disabled. No communications will be send to this contact. emailSubscribe
'optional'
You can set if the contact is subscribed to receiving emails or not.
The default value is false (unsubscribed).true
'optional'
Subscribe contact to emails false
'default'
Unsubscribe contact from emails smsSubscribe
'optional'
You can set if the contact is subscribed to receiving SMS or not.
The default value is false (unsubscribed).true
'optional'
Subscribe contact to SMS false
'default'
Unsubscribe contact from SMS desktopWebPushSubscribe
'optional'
You can set if the contact is subscribed to receiving desktop web push notifications or not.
The default value is false (unsubscribed).true
'optional'
Subscribe contact to desktop webpush notifications false
'default'
Unsubscribe contact from desktop webpush notifications mobileWebPushSubscribe
'optional'
You can set if the contact is subscribed to receiving mobile web push notifications or not.
The default value is false (unsubscribed).true
'optional'
Subscribe contact to mobile webpush notifications false
'default'
Unsubscribe contact from mobile webpush notification telegramSubscribe
'optional'
You can set if the contact is subscribed to receiving Telegram messages or not.
The default value is false (unsubscribed).true
'optional'
Subscribe contact to Telegram messages false
'default'
Unsubscribe contact from Telegram messages firstName
'optional'
Contact’s first name lastName
'optional'
Contact’s last name contactBirthday
'optional'
Contact’s birth date in ENUM_DATE
(YYYY-MM-DD) formatcontactLanguage
'optional'
Contact’s locale in ISO 639-1
formatcontactGender
'optional'
Contact’s gender in ISO/IEC 5218
format0 Not known 1 Male 2 Female 9 Not applicable contactTimezone
'optional'
Contact’s timezone in ISO 8601
formatcontactScore
'optional'
Contact Score avatarLink
'optional'
Link to contact’s avatar image. facebookLink
'optional'
Link to contact’s Facebook profile. instagramLink
'optional'
Link to contact’s Instagram profile. linkedInLink
'optional'
Link to contact’s LinkedIn profile. twitterLink
'optional'
Link to contact’s Twitter profile. tiktokLink
'optional'
Link to contact’s TikTok profile. variables
'optional'
An array of contact variables and their values. name
'required'
Variable name in lowerCamelCase format
IMPORTANT
Please use only latinlowerCamelCase
format. No numbers or other symbols allowed.value
'required'
Variable value in 'ENUM_STRING'
or'ENUM_DATE'
format correspondinglysourceId
'optional'
Contact’s unique source ID from SmartSender platform customerSourceId
'optional'
Contact’s unique source ID from your system to synchronize two sides. IMPORTANT
If you use sourceId and customerSourceId at the same time, sourceId will have higher priority.cac
'optional'
value
'required'
CAC value in 'ENUM_STRING'
format correspondinglycurrency
'required'
(EUR, USD)
IMPORTANT
Please use only latin uppercase format. No numbers or other symbols allowed.