Reply
Highlighted
Visitor
Posts: 1
Registered: ‎08-20-2018

Tracking an interaction on an iframe on a webpage - sending a GA event

I need to track an interaction of an embedded iFrame on a webpage in tealium by sending an event to GA.

Can someone please outline the steps I need to take to make this happen please.  We cant put tealium or GA within the iframe.

Any help or steering massibvely appreciated.

Reply
0 Kudos
Contributor
Posts: 67
Registered: ‎04-20-2016

Re: Tracking an interaction on an iframe on a webpage - sending a GA event

[ Edited ]

Hi @kopkacobana

This is difficult, especially if the iframe is on a different domain.

An event happening in the iframe will bubble up, but only as far as the body tag (so still within the iframe). Which means you can't add a listener to the parent document.

If you can add code to the page in the iframe, then you could try triggering an event on the window using

$(window).trigger("eventname")

 

and then adding the listener via an extension on the parent, using

$(window).on("eventname", function() { ... stuff... });

 

 I have done something a bit hacky in the past where i used an onmouseover handler on the iframe element, and then within that function body I added another event handler for something within the iframe.  I can't really remember the details but it seemed to work reasonably reliably.

Checkout our blog: www.120feet.com/blog