使用Google Analytics和dataLayer(GTM)跟踪WP Post标签 [英] Tracking WP Post Tags using Google Analytics and dataLayer (GTM)

查看:786
本文介绍了使用Google Analytics和dataLayer(GTM)跟踪WP Post标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用发布作者,标签和类别数据设置dataLayer变量。所有这些都已在Analytics(分析)中创建为自定义维度。



问题是Post Tags和Categories是数组,我必须在Google Tag Manager上拆分数组吗? (或类似的东西,IDK)。我做了一个测试,将邮件类别设置为 pageCategory [0] 作为数据层变量名称(因为我只需要第一个类别),但它运行得不好。



dataLayer如下所示:

  {
pagePostType: post,
pagePostType2:single-post,
pageCategory:[ha-kidd-knitting-supplies],
pageAttributes:[big- 时装纱,查尔斯·沃斯,经典色调,易针织,km066,针织罩,纹理罩,万向纱],
pagePostAuthor:Charles Voth
}

什么是最佳方式在Google Analytics中收集所有WordPress的发布标签和类别作为自定义维度? 您需要使用点符号访问数组,所以你的页面cateogry的dataLayer变量可以有一个值,如:

  pageCategory.0 

code>

对于您的页面属性,它们可以是acce单独提供:

  pageAttributes.1 
pageAttributes.2

等。



当然,对于多个页面属性,这不是最好的方法。您应该改为定义dataLayer变量的值为 pageAttributes ,然后您可以遍历此变量来填充自定义维度,然后连接字符串。 p>

I set the dataLayer variable with the post author, tags and categories data. All these were already created as custom dimensions on Analytics.

The problem is that Post Tags and Categories are arrays, Do I have to split the arrays on Google Tag Manager? (Or something like that, IDK). I did a test with Post Categories setting up pageCategory[0] as Data Layer Variable Name (Because I need only the first category) but It's not working good.

The dataLayer looks like this:

{
"pagePostType":"post",
"pagePostType2":"single-post",
"pageCategory":["ha-kidd-knitting-supplies"],
"pageAttributes":["big-time-yarn","charles-voth","classic-shades","easy-knits","km066","knitted-cowl","textured-cowl","universal-yarn"],
"pagePostAuthor":"Charles Voth"
}

What is the best way to collect all the wordpress post tags and categories as custom dimensions on Analytics?

解决方案

You need to use dot notation to access the array, so your page cateogry dataLayer variable could have a value like:

pageCategory.0

For your page attributes, they could be accessed individually:

pageAttributes.1
pageAttributes.2

etc.

Of course with multiple page attributes, this wouldn't be the best way. You should instead define your dataLayer variable to have a value of just pageAttributes, and then you can loop through this variable to populate your Custom Dimensions, and then concatenate the strings.

这篇关于使用Google Analytics和dataLayer(GTM)跟踪WP Post标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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