0

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" }); }
ImASkuller
  • 39
  • 5

1 Answers1

0

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"
});
Дмитро Булах
  • 3,697
  • 1
  • 14
  • 23
  • Actually, I did find that it works the way I had it and I’m surprised by that. Everything I’ve read says that you can’t track events from within an iframe. The reason I couldn’t see that it was working was because it was being filtered out by GA. Do you know why it is working? Are iframes hit or miss? – ImASkuller Jan 24 '19 at 11:57
  • it works because of the source page is on the same domain and you are able to place a tracking tag there. so when it's loaded in the iframe it's tracked in the same way as if it were on a separate tab. in case of a source page from other domain like an embedded content you won't be able to put a tracking tag there and won't have an access to source page from a host page. – Дмитро Булах Jan 24 '19 at 12:50
  • Gotcha. Makes perfect sense. Thanks for your help. – ImASkuller Jan 24 '19 at 12:51