Adding a Javascript Callback to MARE's Tracking Snippet

NOTE: This feature is available to MARE Plus Subscribers Only

If you're looking to export your data to an external program, or to segment your visitors using tracking pixels or other javascript on your website, you can modify MARE's tracking snippet to send survey information to a javascript function that you create.

Here is the information that will be sent back to your javascript function in the form of an object:

  • action (what action the user is taking - format: 'closed','triggered','response')
  • step (what step or question the user is on format: Integer)
  • survey (ID of the survey being answered format: Integer)
  • response (what was the response of the user on this step format: string)
  • is_optin (if this is an optin or lead form format: boolean)

To create the callback, you need to add an array to the MARE tracking snippet at some point BEFORE the tracking snippet starts.

The array can include the following arguments:

  • CUSTOM_VARIABLES (optional)

Here is an example of the array:

var _mare_cb = [

Custom variables are optional, and can be used to further segment your campaign.

The callback function must be available to the MARE script, and therefore cannot be contained in a namespace.

NOTE: If you are using a function contained in a javascript object, you will need to include the object name as well. Here's an example:

var _mare_cb = [

Example callback function

Here is an example function that will receive the data from the MARE snippet, and print it to the console:

var callback_function = function(data,custom) {

The argument 'data' will contain all of the MARE data.

The argument 'custom' will contain all of your custom variables.

Final Snippet Example Code

Here is a look at the final snippet with the callback array included:


  var _mare_pk = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
  var _mare_sc = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
  var _mare_cb = [
  (function() {
    var mare = document.createElement('script'); mare.type = "text/javascript"; mare.async = true;
    mare.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + '';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(mare, s);


Please sign in to leave a comment.
Powered by Zendesk