Google跟踪代码管理器规则来识别流量来源 [英] Google Tag Manager Rule to Identify Traffic Source

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

问题描述

有没有一种方法可以创建一个标识流量源类型的Google标签管理器规则(通过宏)? (像有机?)。想要创建一个只有在流量来源为有机时才会触发的标签。可能吗?

解决方案

最简单的方法是从Google Analytics(__utmz)Cookie中提取源代码(utmcsr)管理器事件基于值。然后根据该事件创建一个规则。



我不认为这完全来自标签管理界面。



(更新后添加)I过去曾经使用过下面的代码,并猜测它仍然可以工作(恐怕我不能给予适当的功劳,我从某个网站捏住了它)。

  / ** 
读取Google utmz Cookie并将其值作为数组返回
utmcsr = utm_source
utmccn = utm_campaign
utmcmd = utm_medium
utmctr = utm_term
utmcct = utm_content * /
function parseGACookie(){
var values = {};
var cookie = readCookie(__ utmz);
if(cookie){
var z = cookie.split('。');
if(z.length> = 4){
var y = z [4] .split('|');
for(i = 0; i< y.length; i ++){
var pair = y [i] .split(=);
值[pair [0]] = pair [1];
}
}
}
返回值;
}

函数readCookie(name){
var nameEQ = name +=;
var ca = document.cookie.split(';');
for(var i = 0; i< ca.length; i ++){
var c = ca [i];
while(c.charAt(0)=='')c = c.substring(1,c.length);
if(c.indexOf(nameEQ)== 0)return c.substring(nameEQ.length,c.length);
}
返回null;
}

ga = parseGACookie();
if(ga ['utmcsr'] ==cpc){
alert(Paid advertising);
}


Is there a way to create a google tag manager rule ( via a macro ) which identifies the traffic source type? ( Like organic ?). Would like to create a tag which only fires if the source of traffic is organic. Possible?

解决方案

Easiest way would be to extract the source (utmcsr) from the Google Analytics (__utmz) Cookie and fire an tag Manager event based on the value. Then create a rule based on that event.

I don't think it's possible solely from the tag manager interface.

(Updated to add) I've used the following code in the past and guess it'll still work (I'm afraid I can't give proper credit, I pinched that from some website).

/**
 Reads the Google utmz Cookie and returns he values as an array
 utmcsr = utm_source
 utmccn = utm_campaign
 utmcmd = utm_medium
 utmctr = utm_term
 utmcct = utm_content  */
function parseGACookie()  {
    var values = {};
    var cookie = readCookie("__utmz");
    if (cookie) {
        var z = cookie.split('.');
        if (z.length >= 4) {
            var y = z[4].split('|');
            for (i=0; i<y.length; i++) {
                var pair = y[i].split("=");
                values[pair[0]] = pair[1];
            }
        }
    }
    return values;
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

ga = parseGACookie();
if(ga['utmcsr'] == "cpc") {
    alert("Paid advertising");
}

这篇关于Google跟踪代码管理器规则来识别流量来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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