如何将 WordPress 帖子的创建月份传递给 Google Analytics 中的自定义变量
我正在尝试将 WordPress 帖子的发布月份注册为 GA 中的页面级自定义变量,但我不知道如何:
- 在 Wordpress 中获取“月份”变量
- 将代码放在单个帖子的标题上仅(没有登陆页面或“关于”页面,例如)
例如,如果帖子是在 12 月创建的,我想将变量“Month”(值为“12”)传递给 GA。
谢谢!
I'm trying to register the month of publishing of my Wordpress posts as a Page-level custom variable in GA, but I don't know how to:
- Get the "month" variable in Wordpress
- Put the code on the header of single posts only (no landing pages or "about" pages, p. ex.)
For example, if a post was created in december, i would like to pass the variable "Month", with the value "12" to GA.
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过执行
。只需将其放在单个页面或帖子模板中需要的任何位置,它就应该传递月份的数值。
You can get the month variable by doing
<?php the_date('m'); ?>
. Just put that whereever you need it within the individual page or post template and it should pass the numerical value of the month.