使用Google跟踪代码管理器跟踪活动 [英] Tracking events using Google Tag Manager

查看:96
本文介绍了使用Google跟踪代码管理器跟踪活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自开始使用Google跟踪代码管理器以来,我一直在尝试为分析提取一些Javascript。
目前,我想跟踪退出链接,并使用以下自定义html片段:

 <脚本类型= 文本/ JavaScript的 > 
$ b $(document).ready(function(){

$('。app-cta a')。onClick = _gaq.push(['_ trackEvent',' App','Click','iOS']);

});
< / script>

发射规则为:

  {{event}}等于GAevent 

然后我尝试了一条触发规则:

  {{url}}与RegEx。* 
匹配

没有运气。 Google Analytics(分析)和HTTPfox中没有任何内容。



我仍然在围绕Google跟踪代码管理器开展工作。



任何人都可以看到我在这里做错了什么? 您需要使用dataLayer.push,而不是_gaq。推,并且你的onClick功能不正确。应该看起来像这样:

 < script> 
$('。app-cta a')。click(function(event){
dataLayer.push({$ b $'event':'GAevent',
'eventCategory' :'App',//创建一个数据层变量宏,名为eventCategory
'eventAction':'点击',//创建一个名为eventAction的数据层变量宏$ b $'eventLabel':'iOS'//创建一个名为eventLabel的数据层变量宏
});
});
< / script>

这个自定义HTML标记应该会触发与{Reg}匹配的{{url}} *。



除了此设置之外,您还需要创建一个新的Google Analytics代码,并添加track type = Event。将您创建的宏(eventCategory等)添加到事件跟踪参数中,并将触发规则设置为{{event}}等于GAevent。


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?

解决方案

You 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.

这篇关于使用Google跟踪代码管理器跟踪活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆