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

Bronze Contributor
Bronze Contributor

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.

1 REPLY 1

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

Tealium Expert
Tealium Expert

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.

Public