Adding setTimeOut to Google Analytics Funtion
I'm having trouble passing Google Analytics parameters on link clicks. It
seems that the problem is that the new page opens before the parameters
are picked up. This leads to a red line in httpfox "ns binding error".
From SO and Google it seems the solution is to use setTimeOut with a
1,000ms delay.
Within Google-Tag-Manager I have the following custom html:
<script>
$('.submit-incident.clearingfix a').click(function(event){
dataLayer.push({
'event':'GAevent',
'eventCategory': 'Report Submit',
'eventAction': 'Link Click',
'eventLabel': 'CTA'
});
});
</script>
I'm not actually sure how to integrate setTimeOut without simply delaying
the whole thing by 1 second.
This didn't work.
<script>
setTimeOut($('.submit-incident.clearingfix a').click(function(event){
dataLayer.push({
'event':'GAevent',
'eventCategory': 'Report Submit',
'eventAction': 'Link Click',
'eventLabel': 'CTA'
});
});),1000);
</script>
And even if it did it wouldn't make sense to me. How would I delay the
page opening for a second so that Google Analytics has enough time to pick
up the dataLayer parameters?
No comments:
Post a Comment