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

Uses for Custom Action Tracking

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:

  1. Purchases
  2. Adding products to cart
  3. Signups
  4. Visiting specific pages
  5. Completing forms
  6. Reaching a certain status/reputation level
  7. Referring friends
  8. 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.

Setting Up the Custom Action

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.

Set up Custom Action Tracking for a Custom 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.

Note

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.

Installing the Tracking Script

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 Script

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.

Tip

If you have the Tab / Overlay installed for a campaign, we can also piggyback off that for tracking.

Action Trigger Script

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>
Tip

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.

Full Script Example

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.

Enabling a Question Fallback

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.

Set up a Question fallback for your Custom Action Tracking

Then ask something that can be used to identify the user like username, order ID or name.

Sending Multiple Values

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>

Tracking Callback

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>

Useful Information

Auto Completion

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.

Daily Entries

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.

Example

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.