如何将 WordPress 帖子的创建月份传递给 Google Analytics 中的自定义变量

发布于 2024-12-25 22:30:14 字数 208 浏览 1 评论 0原文

我正在尝试将 WordPress 帖子的发布月份注册为 GA 中的页面级自定义变量,但我不知道如何:

  1. 在 Wordpress 中获取“月份”变量
  2. 将代码放在单个帖子的标题上仅(没有登陆页面或“关于”页面,例如)

例如,如果帖子是在 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:

  1. Get the "month" variable in Wordpress
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小清晰的声音 2025-01-01 22:30:14

您可以通过执行 。只需将其放在单个页面或帖子模板中需要的任何位置,它就应该传递月份的数值。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文