Use JavaScript events to receive client-side events to be notified about events that happen in your Sideqik promotions.
JavaScript Events Overview
JavaScript events allow you to pass information to other client-side analytics frameworks or execute custom JavaScript code when certain events occur.
Using JavaScript Events in Sideqik
JavaScript events are enabled by default in Sideqik - all you have to do is add code to listen for them.
To register for JavaScript events, you make an API call to Sideqik's JavaScript API and provide a callback function that will receive the data related to that event.
For example:
sideqik('on', '<eventType>', function(data) { // callback code here } )
JavaScript events can be enabled for specific promotions or account-wide.
To enable JavaScript events for all promotions on an account, go to Settings > Integrations, and enable the "Custom Footer" integration.
To enable JavaScript events for a specific promotion, go to Design > Customize look and feel > Customize CSS/HTML, and enter your JavaScript in the Custom HTML field.
JavaScript Example
<script type="text/javascript">
sideqik('on', 'promotion.actionCompleted', function(data) {
console.log("[API DATA] Action Completed event received", data);
});
sideqik('on', 'promotion.entered', function(data) {
console.log("[API DATA] Entered event received", data);
});
</script>
JavaScript Event Types
This is a list of all the types of events we currently send. We may add more at any time, so you shouldn't rely on only these types existing in your code.:
- promotion.entered - triggered when a fan enters a promotion
- promotion.actionCompleted - triggered when a fan completes an action in an action promotion
For an example of the [FAN ENTITY] below, see our REST Documentation.
Event: promotion.entered
Occurs whenever a fan first enters a promotion, and includes information about the promotion, any influencer who referred them to the promotion, and the fan who entered.
Here is an example of the JSON sent for this event:
{
"promotion":{"id":"5a0e5994bcf5672159000017","name":"My Promotion"},
"fan": [FAN ENTITY],
"influencer":{"id":97,"name":"Jane Influencer"}
}
Event: promotion.actionCompleted
Occurs whenever a fan completes an action on an action promotion.
Here is an example of the JSON sent for this event:
{
"promotion":{"id":"5a0e5994bcf5672159000017","name":"My Promotion"},
"action":{"id":"5a0e5994bcf5672159000123","name":"Follow us on Twitter"},
"fan": [FAN ENTITY],
"influencer":{"id":97,"name":"Jane Influencer"}
}
Questions?
We're always happy to help with code or other questions you might have! Send us an email at support@sideqik.com or click the chat icon in the bottom-right corner of Sideqik.
Comments
0 comments
Please sign in to leave a comment.