admin管理员组文章数量:1352795
I've been attempting to pick up a bit of Javascript for analytics since starting to use Google Tag Manager. Currently, I'd like to track exit links and am using the following custom html snippet:
<script type="text/javascript">
$(document).ready(function(){
$('.app-cta a').onClick=_gaq.push(['_trackEvent', 'App', 'Click', 'iOS']);
});
</script>
The firing rules are:
{{event}} equals GAevent
I then tried a firing rule:
{{url}} matches RegEx .*
No luck. Nothing being picked up in Google Analytics nor in HTTPfox.
I'm still getting my head around Google Tag Manager.
Can anyone see what I'm doing wrong here?
I've been attempting to pick up a bit of Javascript for analytics since starting to use Google Tag Manager. Currently, I'd like to track exit links and am using the following custom html snippet:
<script type="text/javascript">
$(document).ready(function(){
$('.app-cta a').onClick=_gaq.push(['_trackEvent', 'App', 'Click', 'iOS']);
});
</script>
The firing rules are:
{{event}} equals GAevent
I then tried a firing rule:
{{url}} matches RegEx .*
No luck. Nothing being picked up in Google Analytics nor in HTTPfox.
I'm still getting my head around Google Tag Manager.
Can anyone see what I'm doing wrong here?
Share Improve this question edited Aug 12, 2013 at 17:42 Doug Fir asked Aug 12, 2013 at 17:23 Doug FirDoug Fir 21.4k54 gold badges191 silver badges340 bronze badges1 Answer
Reset to default 10You need to use dataLayer.push, not _gaq.push, and your onClick function is incorrect. Should look something like this:
<script>
$('.app-cta a').click(function(event){
dataLayer.push({
'event':'GAevent',
'eventCategory': 'App', //create a datalayer variable macro called eventCategory
'eventAction': 'Click', //create a datalayer variable macro called eventAction
'eventLabel': 'iOS' //create a datalayer variable macro called eventLabel
});
});
</script>
This Custom HTML tag should fire {{url}} matches RegEx .*
In addition to this setup, you'll need to create a new Google Analytics tag with track type = Event. Add your macros (eventCategory, etc) that you created into the Event Tracking Parameters, and set the firing rule to {{event}} equals GAevent.
本文标签: javascriptTracking events using Google Tag ManagerStack Overflow
版权声明:本文标题:javascript - Tracking events using Google Tag Manager - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743919702a2561857.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论