Placing Google Analytics code in Wordpress specific page

后端 未结 2 757
温柔的废话
温柔的废话 2021-01-26 10:56

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

相关标签:
2条回答
  • 2021-01-26 11:01

    It sounds like you're trying to add it using the "Visual" view, which formats whatever you put in into paragraphs, etc.

    Try switching to "HTML" view (the tab is at the top right of the input box) and add it there - hopefully that should allow you to add it without converting it!

    Edit: As per my comments below, I made a mistake - it seems even the HTML tab adds some degree of formatting.

    In this case, you may find some use with this plugin:

    http://wordpress.org/extend/plugins/raw-html/

    This allows you to displable to auto formatting on a per-post basis. So on that specific page you could turn off the autoformatting simply to allow you to add that Analytics snippet.

    The only other way I can think off offhand would be to write a custom page_template just for that thankyou page and add it to there. Instructions are here: http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

    0 讨论(0)
  • 2021-01-26 11:13

    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.

    0 讨论(0)
提交回复
热议问题