Sending Data using Our Javascript Snippet

Like many other analytics tools, a simple integration can be done with our javascript snippet. This is a simple way for you to send data to SparkPage from a web app.

When you create an account, we’ll create your unique Javascript snippet. Here’s what the snippet looks like:

You should then include the code before </body> tag on every page where your users are logged in. Note that the items marked as // CHANGE, where you should include your logged in user’s data.

We only require that you send  id (a unique user id), all other fields are optional. However email and created_at are both strongly recommended. You can also send us any addtional user attributes that you will find useful for the growth team to engage with them. 

By default we accept attributes like  fname and lname. These are default attributes and are listed below. In addtion to these, you can track any other user attributes by passing a parameter 'customFields': {'name': 'value pair'}, just like fname and lname in the sample code above. 

You can view our default and your custom attributes in the Settings > User Data.

You can use these any of these attributes in the body of a message or you can use them to segment your users.

You can also use the Javascript to Record User Events. Full details are here.

Limits of the Javascript 

We only track activity when the user is explicitly identified, i.e. when they are logged in. We do not track anonymous user activity.

To update a user’s attributes, just send the “identify” call again with the same id and the new attribute values.

A javascript snippet makes it really easy to get started, but it isn’t essential. You may do everything through our  REST API

User Attribuites

By default, SparkPage will accept the following as User Attributes. Some of these have special properties, e.g. "email" is what we'll use when we trigger an email to that user. Others, like fname and lname, are just generic strings with no meaning beyond simple text.

Name ID Notes
User ID uid REQUIRED The user's unique id. Should match your internal database
First Name fname User's First Name
Last Name lname User's Last Name
Mobile msisdn The user's mobile/cell number. Used for delivering SMS. Should be in  E.164 format. E.G. +15559997777
Email email The user's email address. Even if you use email as a user id (although discouraged) you need to restate it here
City city Used for some location services
Signed Up added A DateTime timestamp of the date & time the user signed up to your service
Device Type device_type Can be "ios" or "android". Used for push notification delivery.
Device Token device_token The unique device token for sending Push Notifications
Note note A plaintext note on the user's account. Useful for CRM purposes
Latitude lat Lat/Long used for location services
Longitude long Lat/Long used for location services
Unsubscribed From Emails unsubscribed_from_emails 1 or 0. Setting this to true (1) will make the user opted-out and we will no longer deliver emails to them
Timezone timezone Used to deliver messages at a certain time in "User's local timezone".  TZ format. E.G. US/Eastern
Age age Will be used for custom reporting in future
Gender gender Will be used for custom reporting in future
Tags tags.tag An array of tags to apply to a user. E.G. "tags" : {'VIP', 'Investor'}

Still need help? Contact Us Contact Us