Will
Will

Reputation: 872

Tracking custom IFRAME events in Google Tag Manager

I have some IFRAMEs on my pages for external services -- AddThis, YouTube, and a JWPlayer-based custom video solution. I want to use GTM to track clicks and responses in those IFRAMEs (particularly 'play' events on the video) but the cross-domain policy prevents that. How do I make that work -- and how do I get it to work in GTM?

Upvotes: 3

Views: 4166

Answers (1)

Will
Will

Reputation: 872

It took me a while to figure it out, but basically:

  • Create a GTM container and add the GTM codeblock to pages on your site.
  • Create a ‘Tag’ to be your event listener.
  • Create two ‘Triggers’: one for which pages to listen for the event, and one that fires when your event happens.
  • Create one or more ‘Variables’ to store the info from your event listener ‘Tag’
  • Create another ‘Tag’ to take the info you stored in the ‘Variables’ and pass it to Google Analytics.
  • Go into the Google Analytics console and watch the events come in.

I wrote up a more complete, long-form guide at https://www.wnet.org/2015/07/09/using-google-tag-manager-for-custom-event-tracking/

Upvotes: 2

Related Questions