setTimeout( function () { if (typeof ga === "undefined") { // Not Google Analytics } else { ga(function (tracker) { // Gets the client ID of the default tracker. var clientId = ga.getAll()[0].get('clientId'); // Gets a reference to the window object of the destionation iframe. var frameWindow = document.getElementById('CBbCCross').contentWindow; // Sends the client ID to the window inside the destination frame. frameWindow.postMessage({type:'GA',clientId:clientId}, '*'); }); } }, 5000); window.addEventListener('message', function(event) { if(event.data.type == 'event'){ gtag('event', event.data.eventAction, event.data.parameters); } });