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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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 http://ieg.wnet.org/blog/using-google-tag-manager-for-custom-event-tracking/