Created
January 20, 2018 15:04
-
-
Save ju1/e3f19e95bd7df2c2a8a5d12266b7ee23 to your computer and use it in GitHub Desktop.
Google Analytics Cross-domain tracking: Find and decorate iFrame
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function() { | |
return function() { | |
try { | |
var gobj = window[window.GoogleAnalyticsObject]; | |
var iframe = document.querySelector('#myIframe'); | |
var tracker, linker; | |
if (gobj) { | |
tracker = gobj.getAll()[0]; | |
linker = new window.gaplugins.Linker(tracker); | |
iframe.src = linker.decorate(iframe.src); | |
} | |
} catch(e) {} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment