在 Wordpress 特定页面中放置 Google Analytics 代码 [英] Placing Google Analytics code in Wordpress specific page

查看:20
本文介绍了在 Wordpress 特定页面中放置 Google Analytics 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在客户填写联系表格后,我试图让 Google Analytics 代码在感谢页面上工作,并且我尝试将其放在感谢页面中,该页面位于 Wordpress 管理下的页面中后端使用 HTML 选项卡,但它似乎在代码之间生成不必要的 p 和 br 标签,尤其是在关闭标签之前.我不确定这是否是导致问题的原因.有没有办法只在一页上做到这一点?

I'm trying to get Google Analytics Code to work on the thank-you page after customer has filled in the contact form and I've tried putting it in the thank-you page which is in the pages under admin in Wordpress backend using HTML tab but it seems to generate unnecessary p and br tags in between codes especially before closing tag. I'm not sure whether that is causing the issue or not. Is there a way we can do this for just one page?

推荐答案

我不是 100% 确定是否可以使用 Wordpress 的 tinyMCE 编辑器插入 javascript.

I'm not 100 % sure whether it's possible at all to insert javascript with the tinyMCE Editor of Wordpress.

如果确实如此,那么您可以尝试以下操作:

If that's true, then you can try the following:

  1. 获取帖子的 ID:当您处于可以查看所有帖子的视图中时,请查看管理菜单中的链接,例如

  1. Get the posts' ID: Look at the linking in your admin menu when you are in the view where you can see all your posts, e.g.

http://www.your-url.com/wp-admin/post.php?post=796&action=edit

796 将是您的 ID.

796 would be your ID here.

在您的 wordpress 主题的 header.php 中输入以下内容(在/wp-content/themes/theme-name 中找到):

Enter the following in your header.php of your wordpress theme (to find at /wp-content/themes/theme-name):

.

  <?php if (is_page(796)) { ?>   
   //YOUR ANALYTICS CODE IN HERE
  <?php } ?>

在此处用您的 ID 替换 796,并将您的分析代码放在 PHP 代码之间.

Replace 796 with your ID here, and put your analytics code in between the PHP code.

这篇关于在 Wordpress 特定页面中放置 Google Analytics 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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