1

Having an issue where I have a client who wants his Google Analytics code on just one page. I'm using the following is_page code but in the footer.php of my child theme, but it's not appearing on the page. Is this code correct?

<?php if ( is_page( 'contact' )) {
    echo '<script type="text/javascript">/* <![CDATA[ */
var google_conversion_id = 000000000;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "000000000";
var google_remarketing_only = false;
/* ]]> */</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"></script>
<noscript><div style="display:inline;"><img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/000000000/?label=000000000&amp;guid=ON&amp;script=0"/></div></noscript>';
} ?>
  • Can you please let me know on which only one page you want to display this Google Analytics code means you can share with me page title, page id and page slug so I can help you with correct code. – Tanmay Patel Mar 3 at 9:56
0

Instead of page slug use page id like is_page(12) where page id 12

Edit Your code should work I afraid your page slug is not same, so it will be safe to use page ID instead of slug

0

If you have mywebsite/contact as url it should appear in the footer. Make sure the slug is "contact" or use page ID as suggested by Zakir. You can find the page ID by going to Pages in the admin area and hover over the contact page. You will see it then on the bottom left of your screen in the url mywebsite/wp-admin/post.php?post=10$action=edit --> post id = 10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.