Help CentreIntegrations Marketing toolsHow to use Google Analytics with Google Tag Manager (GTM). Step 2 - for iframe integration

How to use Google Analytics with Google Tag Manager (GTM). Step 2 - for iframe integration

This help guide is for those looking to track booking activity when SuperControl is integrated on your website via iframes. If you are unsure which method of integration you are using, please contact our support team.

Please complete the steps covered in this article first http://help.supercontrol.co.uk/m/integrations/l/943424-how-to-use-google-analytics-with-google-tag-manager-gtm-to-track-booking-activity

GTM Settings for iframe integrations

Step 1: Create two new Variables

  1. From the left hand menu select 'Variables' and then 'New'
  2. Name the first Variable 'Page Is iFrame'
  3. Click 'Choose a variable type to begin setup...'
  4. Select 'Custom Javascript'
  5. Paste the below code into the custom javascript field and then click Save
function() { try { return window.top !== window.self; } catch(e) { return false; } }
  1. Click 'New' to create your second variable
  2. Name the Variable 'JS - hitCallback for X-Dom iframe'
  3. Click 'Choose a variable type to begin setup...'
  4. Select 'Custom Javascript'
  5. Paste the below code into the custom javascript field. The 'src' URL needs updated to match the iframe URL on your website. If in doubt, please contact our support team to help you with this.
  6. Click Save
function() { return function() { try { var gobj = window[window.GoogleAnalyticsObject]; var iframe = document.querySelector('iframe[src*="https://secure.supercontrol.co.uk/availability/availability_grid.asp?ownerID=82&siteID=106&mode=iframe"]'); var tracker, linker; if (gobj) { tracker = gobj.getAll()[0]; linker = new window.gaplugins.Linker(tracker); iframe.src = linker.decorate(iframe.src); } } catch(e) {} } }

Step 2: Create a new Trigger

  1. From the left hand menu select 'Triggers' and then 'New'
  2. Name the Trigger 'Exception - Page Is In An iFrame'
  3. Click 'Choose a trigger type to begin setup...'
  4. Choose trigger type 'Page View'
  5. This trigger fires on 'Some Page Views'
  6. From the menus choose
    1. 'Page Is iFrame'
    2. 'equals'
    3. 'true'
  7. Click Save (the trigger should look like the screenshot below)

Step 3: Update your Tag

  1. From the left hand menu select 'Tags' and choose 'Universal Analytics'
  2. Click on the Triggering section
  3. Choose 'Add Exception' and select 'Exception - Page Is In An iFrame'
  4. Click Save

Step 4: Save and Publish

  1. Click Submit button (top right corner) to save and Publish your changes.