【问题标题】:Google Tag Manager Custom VariablesGoogle 跟踪代码管理器自定义变量
【发布时间】:2015-08-31 18:56:10
【问题描述】:

我在 head 部分中有变量作为元数据传递:

<meta id="ctl00_BDMeta_UserEmail" name="DCSext.UserEmail" />
<meta id="ctl00_BDMeta_Username" name="DCSext.Username" />
<meta id="ctl00_BDMeta_PageTitle" name="DCSext.PageTitle" />
<meta id="ctl00_BDMeta_PageURL" name="DCSext.PageURL" />

如何通过 GTM 将这些变量传递到 Universal Analytics?

我会创建新的 JavaScript 变量并使用 getelementbyid 传递值吗?

然后在GTM中,新建一个JavaScript变量,当我用全局变量名配置变量时输入新变量new?

【问题讨论】:

    标签: javascript google-analytics google-tag-manager


    【解决方案1】:

    您需要创建一个“自定义 Javascript”变量(不是“Javascript 变量”变量,因为您没有为其提供全局声明的 JS 变量)。

    自定义 JS 变量将用于捕获您需要的值,可能基于您使用 getElementById(或 jQuery)提供的 ID。所以像这样,在你的自定义 JS 标记中:

    function(){
        // do pre-checks to see if meta tag exists
        return $('meta#ct100_BDMeta_UserEmail').attr("name");
    }
    

    【讨论】:

    • 嗨 Nyuen,我只需要声明如下: 'code'function(){ // 预先检查元标记是否存在 return $('meta#ct100_BDMeta_UserEmail'). attr("DCSext.UserEmail"); }'代码'
    • 自定义 JS 是否也同时传递值,还是我必须添加 getElementById JavaScript 行?
    • 自定义 JS 正在返回名称。如何将值返回到 GA?
    猜你喜欢
    • 2023-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-15
    • 2023-03-19
    相关资源
    最近更新 更多