Custom Action Tracking
Business users have the ability to verify the completion of Custom Actions via a Javascript API tracking script. This allows you to build your own actions and fire the tracking when the user has completed them.
Applications that support Custom Action Tracking:
- Competitions
- Rewards
Typically Custom actions require manual tracking, whereby the user might answer a question. Using the Tracking script allows you to more reliably track when users have completed actions on your own site (or partner site).
Typical tracking uses include:
- Purchases
- Adding products to cart
- Signups
- Visiting specific pages
- Completing forms
- Reaching a certain status/reputation level
- Referring friends
- Using specific features
An example might be that you create a Custom action that can be completed by users who have fully completed their Profile on your site. You put the tracking script on the Profile page and trigger it when you know the profile has been fully completed, this way only users that have properly completed the task can be awarded the entries.
To use the Custom Action Tracking first you need to setup a Custom Action.
The Title and Description should explain to the user what they need to do, and also link them out to anywhere they need to go to complete the action.
You must give the action you are unlocking a name like Purchase
, Signup
, Lead
or UserID
. In this example we're using the tracking name VIP
.
Each Custom Action should have a unique tracking name, otherwise you end up mixing up your tracking and letting users unlock multiple actions. For example if you had multiple VIP levels you might use VIP1, VIP2 and VIP3 with each worth more entries.
The Custom action will generate a tracking script that you need to install on your website. The script is broken up into two parts.
Tracking scripts are unique per campaign, they will contain the key of your campaign. You can see the key highlighted in the example script below.
<script>(function(d, t){
var key = '**y2sB7**';
var g = d.createElement(t), s = d.getElementsByTagName(t)[0];
g.src = "https://gleam.io/"+key+"/trk.js"; s.parentNode.insertBefore(g, s);
}(document, "script"));
</script>
You should place this script into the <head>
of your website, or page that you want to trigger the Custom Action on.
If you have the Tab / Overlay installed for a campaign, we can also piggyback off that for tracking.
The section part of the script is what you need to fire in order to unlock the Custom Action. This will also be provided during setup.
The script below will trigger the action with the Tracking name of VIP
.
<script>
window.Gleam = window.Gleam || [];
Gleam.push(['VIP', 'myValue']);
</script>
You can also replace myValue with your own custom value which will get passed back to Gleam:
<script>
window.Gleam = window.Gleam || [];
Gleam.push(['UserID', '123456']);
</script>
Your custom value will show in the Details column in the Actions tab of your campaign.
This can be useful to help de-duplicate or show extra data, like which coupon a person used or perhaps what their UserID
or OrderID
is.
Your full script on the page should end up looking something like this:
<script>(function(d, t){
var key = 'y2sB7';
var g = d.createElement(t), s = d.getElementsByTagName(t)[0];
g.src = "https://gleam.io/"+key+"/trk.js"; s.parentNode.insertBefore(g, s);
}(document, "script"));
</script>
<script>
window.Gleam = window.Gleam || [];
Gleam.push(['UserID']);
</script>
Firing this will unlock the custom action assigned to UserID
for the campaign y2sB7
.
In some cases you may wish to enable a question as a fallback for your tracking. To do this simply select "Allow question or tracking" when setting up your custom action.
Then ask something that can be used to identify the user like username, order ID or name.
If you wish to send multiple values at once, you can do this by sending an array of name/value (with value being optional) arrays:
<script>
window.Gleam = window.Gleam || [];
Gleam.push(['userId', '1234'], ['userName', 'bob1337'], ['taskPerformed']]);
</script>
If you send a send a name/value pair with the name callback
and a JavaScript function, that function will be called when the tracking has successfully sent.
<script>
window.Gleam = window.Gleam || [];
Gleam.push(['userId', '1234'], ['callback', function () { alert("Tracking sent") }]);
</script>
The Custom action will periodically poll the campaign and auto complete when the user has unlocked the action, this means that it can be completed even if the user has left the campaign landing page.
If you have the tracking set to daily it will expire any existing tracking and the user will have to fully complete the action the following day to get the daily entries.
Here's a working example of the API unlock being used when a user visits a particular page.
See Next Article
Custom CSS
Business users have the ability to add or edit the CSS contained within the Gleam widget. This feature enables you to align the style of the campaign with your own website or branding.