-
AuthorPosts
-
January 11, 2016 at 12:02 pm #741129
Hey guys
I’m using Cornerstone’s Custom JS to insert a Google Adwords Conversion Tracking code in some pages.
When I analyze the code with Google Tag Assistant, it shows some critical errors that are avoiding the conversions to be tracked.
Attached are the printscreens of the inserted code and the errors
What am I doing wrong?
Thanks a lot!
January 11, 2016 at 1:47 pm #741259Hi there,
Please setup a child theme and then add this code in the functions.php:
function my_googleremark_footer_output() { if(is_page( 42 )){ ?> <!– Google Code for Contact Form Conversion Conversion Page –> <script type="text/javascript"> /* <![CDATA[ */ var google_conversion_id = 962159383; var google_conversion_language = "en"; var google_conversion_format = "2"; var google_conversion_color = "ffffff"; var google_conversion_label = "f3o2CMmgp1kQl8blygM"; var google_remarketing_only = false; /* ]]> */ </script> <script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"> </script> <noscript> <div style="display:inline;"> </div> </noscript> <?php }} add_action( 'wp_footer', 'my_googleremark_footer_output', 99 );
Please replace the entire script block with your own custom code and change 42 in the code with the page id of your thank you page.
Here is how to locate page id https://theme.co/x/member/kb/how-to-locate-post-ids/
Hope that helps.
January 13, 2016 at 9:37 pm #745365Hey guys
Sorry about the silly question, but if I have more then one page I need to track, can I insert more of this code on ‘functions.php’?
Do I need to write a ifelse or something like that? Or just copy/paste below?
Thanks a lot!!
January 13, 2016 at 9:44 pm #745373Hi there,
Yes, you’ll have to add your tracking code within if-else block. Or the simplest, switch statement.
function my_googleremark_footer_output() { if ( !is_page() ) return; //If not a page, then exit $page_id = get_the_ID(); switch( $page_id ) { //For page that has 42 ID -- START case 42 : ?> <!– Google Code for Contact Form Conversion Conversion Page –> <script type="text/javascript"> /* <![CDATA[ */ var google_conversion_id = 962159383; var google_conversion_language = "en"; var google_conversion_format = "2"; var google_conversion_color = "ffffff"; var google_conversion_label = "f3o2CMmgp1kQl8blygM"; var google_remarketing_only = false; /* ]]> */ </script> <script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"> </script> <noscript> <div style="display:inline;"> </div> </noscript> <?php break; //For page that has 42 ID -- END //For page that has 43 ID -- START case 43 : ?> <!– Google Code for Contact Form Conversion Conversion Page –> <script type="text/javascript"> /* <![CDATA[ */ var google_conversion_id = 962159383; var google_conversion_language = "en"; var google_conversion_format = "2"; var google_conversion_color = "ffffff"; var google_conversion_label = "f3o2CMmgp1kQl8blygM"; var google_remarketing_only = false; /* ]]> */ </script> <script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"> </script> <noscript> <div style="display:inline;"> </div> </noscript> <?php break; //For page that has 43 ID -- END } } add_action( 'wp_footer', 'my_googleremark_footer_output', 99 );
Cheers!
-
AuthorPosts