Search code examples
iframegoogle-analyticshtml5-videotealium

Need Help Measuring Users Clicking PLay on Video That's Sitting in iFrame (Tealium/GA)


I am trying to use Tealium to send the amount of times users have clicked play on the video and sending the data to Google Analytics. There is an iframe on the home page and the secondary page has the content for the iframe. I am having trouble sending the data to GA. If I go directly to the secondary page it does send the info, but if I go through the home page and click play on the video it doesn't send data to GA. Can someone give me a solution for this? I would really appreciate it. Thanks.

Below is the iframe code that's on the home page;

Secondary Page

function myVideo(){ window.$DataTracking.SendForData({ "event_category" : "Video", "event_action" : "Played Video", "event_label" : "Home Page Video" }); }

Solution

  • You cannot track clicks inside iframe from the host page. But as soon as you can out tracking code on the secondary page you may use some trick to make the thing work.

    When the secondary page is loaded in an iframe on some host page its referrer points to host page URL on which an iframe was loaded. You may use this value to override dl parameter of your event hit so Analytics would track this event as happened on the host page. I can't point you to the Tealium code for that but in plain analytics that would look like:

    ga("set", "location", document.referrer);
    ga("send", {
          "hitType" : "event",
          "event_category" : "Video",
          "event_action" : "Played Video",
          "event_label" : "Home Page Video"
    });