News! SmartSender.io becomes Wooxy. Read a post from the CEO Arrow
January 11, 2022

How to create and update contact via JS

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.wooxy.com/js/v2/JS_SCRIPT_ID.js" charset="UTF-8">

</script>

Contact identificator:

<script type="text/javascript">

    let contact = new _wooxyContact('{{identifier}}');

</script>

JavaScript API gif

Step-by-step instructions:

  • To add a new user to the Contact List see example:
    Icon caret

    <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: "male",

            contactTimezone: "Europe/Tallinn",

            contactScore: 100,

            avatarLink: "img.wooxy.com/g/06c38b4568.jpg",

            facebookLink: "https://www.facebook.com/wooxy.com",

            instagramLink: "instagram.com/wooxy",

            linkedInLink: "linkedin.com/company/wooxy"

            twitterLink: "twitter.com/wooxy",

            tiktokLink: "tiktok.com/wooxy",

            sourceId: "Source_ID_from_Wooxy",

            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 be valid 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) format
    contactLanguage 'optional'Contact’s locale in ISO 639-1 format
    contactGender 'optional'Contact’s gender in ISO/IEC 5218 format
    0Not known
    1Male
    2Female
    9Not applicable
    contactTimezone 'optional'Contact’s timezone in ISO 8601 format
    contactScore '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 latin lowerCamelCase format. No numbers or other symbols allowed.
    value 'required'Variable value in 'ENUM_STRING' or 'ENUM_DATE' (YYYY-MM-DD) format correspondingly
    sourceId 'optional'Contact’s unique source ID from Wooxy.com 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 correspondingly
    currency 'required'(EUR, USD) WARNING: Please use only latin uppercase format. No numbers or other symbols allowed.
Add a new user via JavaScript API gif
  • To update contact data in the Contact List see example:
    Icon caret

    <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: "male",

            contactTimezone: "Europe/Tallinn",

            contactScore: 100,

            avatarLink: "img.wooxy.com/g/06c38b4568.jpg",

            facebookLink: "https://www.facebook.com/wooxy.com",

            instagramLink: "instagram.com/wooxy",

            linkedInLink: "linkedin.com/company/wooxy"

            twitterLink: "twitter.com/wooxy",

            tiktokLink: "tiktok.com/wooxy",

            sourceId: "Source_ID_from_Wooxy",

            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 be valid 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) format
    contactLanguage 
    'optional'
    Contact’s locale in ISO 639-1 format
    contactGender 
    'optional'
    Contact’s gender in ISO/IEC 5218 format
    0Not known
    1Male
    2Female
    9Not applicable
    contactTimezone 
    'optional'
    Contact’s timezone in ISO 8601 format
    contactScore 
    '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 latin lowerCamelCase format. No numbers or other symbols allowed.
    value 
    'required'
    Variable value in 'ENUM_STRING' or 'ENUM_DATE' format correspondingly
    sourceId 
    'optional'
    Contact’s unique source ID from Wooxy.com 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 correspondingly
    currency 
    'required'
    (EUR, USD) 
    IMPORTANT: Please use only latin uppercase format. No numbers or other symbols allowed.