通过 Google Tag Manager 访问由 Google Analytics 设置的 ClientID [英] Accessing ClientID set by Google Analytics through Google Tag Manager

查看:28
本文介绍了通过 Google Tag Manager 访问由 Google Analytics 设置的 ClientID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了一个新的Universal Analytics 跟踪,并且希望将 ClientID 存储在一个自定义维度槽中.

I have setup a new Universal Analytics tracking and would like to store ClientID in one of the custom dimensions slots.

跟踪标签是通过 Google 标签管理器(使用预定义的 UA 标签)实现的,我很难通过基本的网页浏览请求传递客户端 ID(通过自定义 JavaScript 宏).

The tracking tags are implemented through Google Tag Manager (using the predefined UA tag) and I am having the difficulty to passing the Client ID (via custom JavaScript Macro) with the basic pageview request.

我已经命名了我的跟踪器以便我可以访问它并且此代码在控制台中运行时没有任何错误,但是当与 GTM 一起使用时,它返回一个错误.

I have named my tracker so that I can access it and this code runs without any error in console, however when used with GTM, it's returning an error.

ga.getByName('trackerGTM').get('clientId'))

产生错误:

Uncaught ReferenceError: ga is not defined

有什么建议吗?

推荐答案

我假设您正在触发页面浏览 {{url}} 匹配 RegEx .*,对吗?可能是 Universal 尚未加载.你试过 {{event}} 等于 gtm.dom 吗?我还没有测试过这个,但这是一个想法.

I assume you're firing the pageview {{url}} matches RegEx .*, correct? Could be that Universal hasn't loaded yet. Have you tried {{event}} equals gtm.dom? I haven't tested this, but it's a thought.

这看起来像是一个错误.我能够运行:

This looks like a bug. I was able to run:

function(){
  var client = ga.getAll()[0].get('clientId');
  return client;

}

让它毫无问题地吐出客户端 ID.

And have it spit out the client ID with no problem.

这篇关于通过 Google Tag Manager 访问由 Google Analytics 设置的 ClientID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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