Google Tag Manager - Basic "Referrer URL" Method

A guide to using this method for event tracking on embedded NBI Widget

If you are using the “Basic setup“ for embedding the Google Analytics or Google Tag Manager codes into your website, there are some restrictions that come with it, since the widget is inside an iframe. Firstly your tracking events will not be able to pass information about the host website along with it. This is because the Now Book It widget is not allowed to receive information from the host website for security reasons.

However, in GTM you can view extra information from the url of the widget. So if you wanted to pass, for example, the referring website’s url, you could do the following:

To Start, Under "Workspace -> Variables" create a new user defined variable and call it something like "Custom Fragment Referrer"


GTM-BasicReferrerURLMethod-1

GTM-BasicReferrerURLMethod2

  1. Choose "URL" as the "Variable type"

  2. Choose "Fragment" as the "Component type"

    GTM-BasicReferrerURLMethod3
  3. Save the variable and publish it

  4. Add the following fragment#referrer=MY_REFERRER_URLto the iframe’s url, replacing "MY_REFERRER_URL" with your custom url.

  5. Now when an event is triggered in Google Tag Manager it will also contain the variable "Custom Fragment Referrer" with your value in it.

     

    GTM-BasicReferrerURLMethod4


The property "referrer" will also be added to the dataLayer's "eventModel" object, if you wish to use this for your variable's source instead of the URL's Fragment.

GTM-BasicReferrerURLMethod5