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

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

问题描述

在客户填写联系表单后,我试图让Google Analytics代码在感谢页面上工作,并试图将其放入WordPress中管理员的页面中的感谢页面后端使用HTML标签,但似乎在代码之间生成不必要的p和br标签,特别是在关闭标签之前。我不确定这是否会导致问题。
有没有一种方法可以只用一页来完成这项工作?

解决方案

我不是100%确定是否插入JavaScript与Wordpress的tinyMCE编辑器是完全可能的。



如果是这样,那么您可以尝试以下操作:


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

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



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

  2. code><?php if(is_page(796)){?>
    //您的分析代码
    <?php}?>

    将796替换为您的ID,然后将分析代码放在PHP代码之间。


    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?

    解决方案

    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. 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 would be your ID here.

    2. 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 } ?>
    

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

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

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