Skip to content

Instantly share code, notes, and snippets.

View rafaelperozin's full-sized avatar

Rafael Perozin rafaelperozin

View GitHub Profile
@rafaelperozin
rafaelperozin / GTM Custom JavaScript Trigger
Last active September 30, 2019 10:49
Tag Manager Custom JavaScript Trigger and Custom Variable to track a third-party iFrame interaction
// Add focus on current window
window.focus();
// When click on iframe the focus change and we are listen this
var listener = window.addEventListener('blur', function() {
//console.log('active == iFrame: ', document.activeElement == document.querySelector('iframe[title="Help Scout Beacon"]'));
// if the current focus is on your iFrame (you can use any css or js selector here)
if (document.activeElement == document.querySelector('iframe')) {