Google adwords conversion tracking code - not working :-(

I have added some google adwords code to a thank you page here

http://www.firstcommunionportraits.co.uk/thank/

Using a chrome plugin (tag assistant by google) I am able to see that google sees the code but the plugin reports it as non standard. I haven't changed anything just cut and pasted it!

I used the html tab to cut and paste the code from adwords and I'm worried that wordpress might have reformatted it?

What is the best way to add adwords conversion tracking code? Do I need to use a plugin?

Here is the code I added but it is NOT being verified by my adwords account.

<!-- Google Code for FirstCommunion Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 978638497;
var google_conversion_language = "en";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "9Pc7CPeo8AgQoa3T0gM";
var google_conversion_value = 1.000000;
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/978638497/?value=1.000000&label=9Pc7CPeo8AgQoa3T0gM&guid=ON&script=0"/>
</div>
</noscript>

  • Dermot Murphy
    • Design Lord, Child of Thor

    Hi Ari.

    It's just a chrome plugin (tag assistant by google) that allows you to view a page and reposts the status of google code.

    I don;t know why but I just suspect that there may be issues cutting a pasting code into a wordpress page even via the html tab?

    But I don;t know how to edit the page directly via ftp or even is this should be necessary? I have seen adwords plugins but they aren;t by google and may break so I would rather hardcode if possible.

    Tnx

    Dermot

  • Dermot Murphy
    • Design Lord, Child of Thor

    I notice line 387 on this page had altered the google scrip code to

    /* ]]> */ (Note when I post here it changes what I see on the view source page)

    when it should read /* ]]> */

    the &gt is not in the original code! view-source:http://www.firstcommunionportraits.co.uk/thank/

    How will I get aroudn this as I don;t know how to eidt the code directly and I'm not sure if there is a plug that will allow me to add the code? WPrdpress seems to mess with it!!

  • Dermot Murphy
    • Design Lord, Child of Thor

    Thanks, Not sure I can get that google publisher plugin to work and also not sure it is relevant to Google Adwords Conversion code? Adsense yes but that's not adwords.

    Still stuck on this and it wont work as it appears the wp engine is rewriting extra characters into the google code and adulterating it when you save the page.

    Any suggestions to stop this behaviour?

    Thank you for your help.

  • Dermot Murphy
    • Design Lord, Child of Thor

    Unfortunately not. Spoke to google who said it's a Wordpress issue. Somehow the google source code is being reformatted by the wp engine (I think)...so unless I manually upload a html page that I can edit that is not in the Wordpress database I cant't think of a way round this?

    Dermot

  • aristath
    • Recruit

    Well, you could try something like this:

    First, create a new file in your wp-content/mu-plugins folder (if that folder does not exist, you will have to manually create it).
    So let's suppose your new file is wp-content/mu-plugins/adwords-code.php

    In that file, paste the following:

    <?php
    
    function my_custom_adwords_code() ?>
    
      PASTE THE CODE YOU HAVE FROM ADWORDS HERE
    
      <?php
    }
    add_action( 'wp_footer', 'my_custom_adwords_code' );

    Of course replace the PASTE THE CODE YOU HAVE FROM ADWORDS HERE part with the actual code you want to add... :slight_smile:

    That should do it. The code will be automatically added to the footer of ALL your pages.

    I hope that helps!

    Take care,
    Ari.

  • Dermot Murphy
    • Design Lord, Child of Thor

    Thanks Ari.

    This is great and I will try it BUT only one thing.

    The way the conversion code works is that it tracks a SINGLE PAGE (on which it sees the code) so for example on a THNK YOU page that is displayed after a visitor complex a WEBFORM page.....when the THNK YOU page pops up the code is triggered and Goggle Adwords recognises it and records it as a conversion.

    So what would I need to do to modify the above to work on just a single page (sorry if this is s silly question!).

    Tnx

    Demot

  • Hoang Ngo
    • Code Slayer

    Hi Demot

    So if you want the code work for single page,this should be like this

    <?php
    
    function my_custom_adwords_code() ?>
      if(get_the_ID()==PAGE_ID){
         PASTE THE CODE YOU HAVE FROM ADWORDS HERE
      }
      <?php
    }
    add_action( 'wp_footer', 'my_custom_adwords_code' );

    Which the PAGE_ID is your thankyou page id for example.

    Best Regards
    Hoang

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.