1. Help Center
  2. Help for Activity Providers
  3. ActivityHero Services, Business Marketing & Analytics

Adding pixel code to track page views and conversions in Google, Facebook and other 3rd party analytics software

You can add any custom tracking code from 3rd party analytics software to track pageviews and conversions of your pages and registrations on ActivityHero. We support purchase conversion tracking on the following platforms. You will be able to see the number of purchases and the revenue from transactions processed on ActivityHero for your activities.

E-Commerce Tracking on Google Analytics - We track page views of your ActivityHero business page, activity page, cart page, checkout page, widget and purchase conversion events. You need to give us your Google Analytics (GA) account ID and add the activityhero.com domain in your GA code snippet below. You can find detailed documentation on cross-domain measurement in GA here.

ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true});
  ga('require', 'linker');
  ga('linker:autoLink', ['activityhero.com']);

 

Google Analytics tracking for an ActivityHero widget - If you want to enable cross-domain linking for conversions on the ActivityHero widget there are a few additional steps that need to be followed on your end.

Copy and paste below code in the head tag of your page and make sure it’s executed on all the pages:
<script>
var _customTask = function () {

  // customTask Builder by Simo Ahava

  //

  // More information about customTask: https://www.simoahava.com/analytics/customtask-the-guide/

  //

  // Change the default values for the settings below.

  // iframeDecorator: Configuration object for decorating any iframe with cross-domain parameters when this customTask is run. NOTE! Increasingly inefficient with today's browsers blocking third-party cookies - please read the article linked to below.

  // https://bit.ly/2LUoWFf

  var iframeDecorator = {

    selector: 'iframe.ah-iframe',

    attempts: 10,

    intervalMs: 1000,

    useAnchor: false

  };

  // DO NOT EDIT ANYTHING BELOW THIS LINE

  var readFromStorage = function (key) {

    if (!window.Storage) {

      // From: https://stackoverflow.com/a/15724300/2367037

      var value = '; ' + document.cookie;

      var parts = value.split('; ' + key + '=');

      if (parts.length === 2) {

        return parts.pop().split(';').shift();

      }

    } else {

      return window.localStorage.getItem(key);

    }

  };

  var writeToStorage = function (key, value, expireDays) {

    if (!window.Storage) {

      var expiresDate = new Date();

      expiresDate.setDate(expiresDate.getDate() + expireDays);

      document.cookie = key + '=' + value + ';expires=' + expiresDate.toUTCString();

    } else {

      window.localStorage.setItem(key, value);

    }

  };

  var globalSendHitTaskName   = '_ga_originalSendHitTask';

  return function (customTaskModel) {

    window[globalSendHitTaskName] = window[globalSendHitTaskName] || customTaskModel.get('sendHitTask');

    // iframeDecorator

    if (typeof iframeDecorator === 'object' && typeof iframeDecorator.selector === 'string' && typeof iframeDecorator.attempts === 'number' && typeof iframeDecorator.intervalMs === 'number') {

      var _id_decorateTimer;

      var _id_count = 0;

      var _id_ga = window[window['GoogleAnalyticsObject']];

      var _id_tracker = _id_ga.getByName(customTaskModel.get('name'));

      var _id_decorateIframe = function () {

        var _id_iframe = document.querySelector(iframeDecorator.selector);

        if (_id_iframe !== null && /[?&]_ga=/.test(_id_iframe.src)) {

          window.clearInterval(_id_decorateTimer);

          return;

        }

        if (_id_iframe === null) {

          _id_count += 1;

          if (_id_count === iframeDecorator.attempts) {

            window.clearInterval(_id_decorateTimer);

          }

          return;

        }

        window.clearInterval(_id_decorateTimer);

        _id_iframe.src = (new window.gaplugins.Linker(_id_tracker)).decorate(_id_iframe.src, iframeDecorator.useAnchor);

      };

      _id_decorateTimer = window.setInterval(_id_decorateIframe, iframeDecorator.intervalMs);

    }

    // /iframeDecorator

    customTaskModel.set('sendHitTask', function (sendHitTaskModel) {

      var originalSendHitTaskModel = sendHitTaskModel,

          originalSendHitTask      = window[globalSendHitTaskName],

          canSendHit               = true;

      try {

        if (canSendHit) {

          originalSendHitTask(sendHitTaskModel);

        }

      } catch(err) {

        originalSendHitTask(originalSendHitTaskModel);

      }

    });

  };

};

</script>

 

  • When you want to invoke this customTask in your trackers, find where you are creating the tracker and make the following change:

ga('create', 'UA-XXXXXXX-X');

ga('set', 'customTask', _customTask()); // <-- Add this right after creating the tracker

ga('require', 'linker'); // enable linker plugin

ga('linker:autoLink', ['activityhero.com']); //specify activityhero.com in the auto link domains

ga('send', 'pageview');

 

    • Now if anyone visits a page your website utm tracking params and then add items in the cart on ActivityHero widget embedded on your website and then make the purchase. Attributed source/campaign should be reflected on your Google analytics account.

Enabling linking via Google Tag Manager (GTM)

  1. Login to your Google Tag Manager account
  2. Click Variables in the left menu and then click New  - Refer screenshot
  3. From the right side panel choose - Custom Javascript - Refer screenshot
  4. Copy and paste below code as value of this variable

function () {

  // customTask Builder by Simo Ahava

  //

  // More information about customTask: https://www.simoahava.com/analytics/customtask-the-guide/

  //

  // Change the default values for the settings below.

 

  // iframeDecorator: Configuration object for decorating any iframe with cross-domain parameters when this customTask is run. NOTE! Increasingly inefficient with today's browsers blocking third-party cookies - please read the article linked to below.

  // https://bit.ly/2LUoWFf

  var iframeDecorator = {

    selector: 'iframe.ah-iframe,

    attempts: 10,

    intervalMs: 1000,

    useAnchor: false

  };

 

  // DO NOT EDIT ANYTHING BELOW THIS LINE

  var readFromStorage = function (key) {

    if (!window.Storage) {

      // From: https://stackoverflow.com/a/15724300/2367037

      var value = '; ' + document.cookie;

      var parts = value.split('; ' + key + '=');

      if (parts.length === 2) {

        return parts.pop().split(';').shift();

      }

    } else {

      return window.localStorage.getItem(key);

    }

  };

 

  var writeToStorage = function (key, value, expireDays) {

    if (!window.Storage) {

      var expiresDate = new Date();

      expiresDate.setDate(expiresDate.getDate() + expireDays);

      document.cookie = key + '=' + value + ';expires=' + expiresDate.toUTCString();

    } else {

      window.localStorage.setItem(key, value);

    }

  };

 

  var globalSendHitTaskName   = '_ga_originalSendHitTask';

 

  return function (customTaskModel) {

 

    window[globalSendHitTaskName] = window[globalSendHitTaskName] || customTaskModel.get('sendHitTask');

 

    // iframeDecorator

    if (typeof iframeDecorator === 'object' && typeof iframeDecorator.selector === 'string' && typeof iframeDecorator.attempts === 'number' && typeof iframeDecorator.intervalMs === 'number') {

      var _id_decorateTimer;

      var _id_count = 0;

      var _id_ga = window[window['GoogleAnalyticsObject']];

      var _id_tracker = _id_ga.getByName(customTaskModel.get('name'));

      var _id_decorateIframe = function () {

        var _id_iframe = document.querySelector(iframeDecorator.selector);

        if (_id_iframe !== null && /[?&]_ga=/.test(_id_iframe.src)) {

          window.clearInterval(_id_decorateTimer);

          return;

        }

        if (_id_iframe === null) {

          _id_count += 1;

          if (_id_count === iframeDecorator.attempts) {

            window.clearInterval(_id_decorateTimer);

          }

          return;

        }

        window.clearInterval(_id_decorateTimer);

        _id_iframe.src = (new window.gaplugins.Linker(_id_tracker)).decorate(_id_iframe.src, iframeDecorator.useAnchor);

      };

      _id_decorateTimer = window.setInterval(_id_decorateIframe, iframeDecorator.intervalMs);

    }

    // /iframeDecorator

 

    customTaskModel.set('sendHitTask', function (sendHitTaskModel) {

 

      var originalSendHitTaskModel = sendHitTaskModel,

          originalSendHitTask      = window[globalSendHitTaskName],

          canSendHit               = true;

 

      try {

 

        if (canSendHit) {

          originalSendHitTask(sendHitTaskModel);

        }

 

      } catch(err) {

        originalSendHitTask(originalSendHitTaskModel);

      }

 

    });

 

  };

}

        1. Save variable with name customTask - Refer screenshot
        2. Add one more variable for Google Analytics settings - Refer screenshot
          1. Specify your Google Analytics ID
          2. Expand more settings, click Fields to set, click Add Field button
          3. Add field - customTask ->
          4. Add field - allowLinker -> true
          5. Expand Cross Domain Tracking
          6. In the Auto Link Domains, enter - activityhero.com
          7. Click Save on the top right
        3. From the left menu, click Tags and add a new Tag - Refer screenshot
        4. Specify GA settings variable  -
        5. Add trigger to execute this tag on all the pages - Refer screenshot
        6. Save tag
        7. Test by clicking the preview on the top and then submit your tag
        8. Now if anyone visits a page your website utm tracking params and then add items in the cart on ActivityHero widget embedded on your website and then make the purchase. Attributed source/campaign should be reflected on your Google analytics account.

Google Ads: We track purchase conversion on thank you page after the user completes a purchase of your activity. You need to give us your Google Ads conversion pixel.

URL Based Page View (FB tracking url or any other tracking url): We need a url, which is placed as an image pixel on you ActivityHero business page, activity page, cart page, checkout and thank you page. For FB, you need to give us your FB conversion pixel code and we will add the correct tracker for your pixel.

Custom: We just need custom script html and we place this script on ActivityHero business page, activity page, cart page, checkout page, widget and thank you page. Just give us the custom script and we will add the tracking for you.

    1.