Custom events allow users to add custom events to their subscribers to be used for segmentation and in turn targeted notifications.
Custom events allow users to add custom events to their subscribers to be used for segmentation and in turn targeted notifications.
All events can have up to 5 different pieces of information, while only 2 are required.
- category - Required. (string or integer)
- action - Required (string or integer)
- label - Optional. (string or integer)
- value - Optional. (integer)
- variables - Optional (object of strings or integers)
Option 1) Tracking Custom Events With The Javascript API
Once you have added your website and integrated the tracking code into your site, you are able to start adding custom events. To do so simply call the following snippet on your page, and replace the variables within the parameters with the information you want to track.
Note: Category and Action are required fields while Label and Value are optional. The value must be a numeric value.
<script>
_at.track("event", {
"category" : "A",
"action" : "B",
"label": "C",
"value" : 1 ,
"variables": {
"name": "value"
}
})
</script>
For instance, if you wanted to track whenever someone watched a video on your page, you could create the following event. Below is an example of tracking a custom event.
<script>
_at.track("event", {
"category" : "Video",
"action" : "Watched",
"variables": {
"name": "3 Ways To Leverage Push",
"url" : "https://abc.com/push"
}
})
</script>
See more on Variables and how they are meant for additional personalization within pushes.
You may also tie an event to a link or button like this:
<button onclick='_at.track("event", { "category" : "Video", "action" : "Watched" })'>Watch Video Event</button>
Option 2) Tracking Custom Events With The REST API
To add the custom attributes via a REST call check out our documentation at https://developers.aimtell.com. Essentially you will just need to make an authenticated call and pass the custom data like the example below.
curl -XPOST -H 'X-Authorization: AUTH_TOKEN' -H "Content-type: application/json" -d '{
"idSite": "1",
"subscriber_uid": "5059b0a2-747d-0f74-73c4-24c8442de237",
"event": {
"category" : "video",
"action" : "watched"
}
}' 'https://api.aimtell.com/prod/subscriber/'
Verifying Events
To help in debugging event tracking, you can check out your logs under "Logs" -> "Event Logs" in your dashboard.