View Single Post
  #1  
Old 12-27-2005, 01:29 PM
 
btomasie btomasie is offline
 

Advanced Member
  
Join Date: Oct 2004
Posts: 80
 

Default Google Adwords Conversion Tracking: a how-to on adding code

I recently added the AdWords Conversion Tracking code into my X-Cart store (version 4.0.14) by going through several threads here on the forum. All of them had only bits and pieces of how to clearly add the code into your store. So I wanted to post all the things I did and provide a cut/paste of my code with some explanation and options as far as the little Google displayed message.

STEPS:
1.) First off, you need to activate the Conversion Tracking portion in your AdWords account. You need to do this only to get your account's Conversion ID number. NOTE: your AdWords customer ID is NOT your Conversion ID. You'll get this Conv. ID number after you answer a few questions inside their step-through and will finally get to a point that they tell you to click inside the textarea box to copy the code for your store. You DO NOT want to use their code, you only want to dig out of it your "google_conversion_id".

2.) Make a backup of your skin1/customer/main/order_message.tpl file.

3.) Inside your order_message.tpl file, locate the {/section} code (line 19 in my v4.0.14 file) and add a few blank lines inbetween that and the {/if} on line 18.

4.) paste the following in:
Code:
{literal} <script language="JavaScript" type="text/javascript"> <!-- var google_conversion_id = 1234567890; var google_conversion_language = "en_US"; var google_conversion_format = "1"; var google_conversion_color = "FFFFFF"; if ({/literal}{$orders[oi].order.subtotal}{literal}) { var google_conversion_value = {/literal}{$orders[oi].order.subtotal}{literal}; } var google_conversion_label = "Purchase"; //--> </script> {/literal}

NOTE: this snippet of code is a little different (i.e. it's not all the code) than what others have posted, but let me get to the next few steps and it'll all fall into place and make more sense.

5.) replace the "1234567890" above with your 10-digit Conversion ID number. Again, this number is NOT your AdWords customer ID.

6.) Step 4 only added the first half of the code. The second half is actual displayed sentence that Google forces us to show. It looked really stupid to have it as part of the above, because it was showing right above the "Print Invoice" and Continue Shopping button. So what I decided to do, is to insert a few blank lines under that piece of default code, and then display this Google text....

7.) locate this piece of default code:
Code:
<TABLE border="0" width="100%"> <TR> <TD align="left">{include file="buttons/button.tpl" button_title=$lng.lbl_print_invoice href="order.php?mode=invoice&orderid=`$orderids`" target="preview_invoice"}</TD> <TD align="right">{include file="buttons/button.tpl" button_title=$lng.lbl_continue_shopping style="button" href="home.php"}</TD> </TR> </TABLE> {/if}

and add a few blank lines inbetween the </TABLE> and the {/if}. Now add this second half of the Conversion code:
Code:
{literal} <script language="JavaScript" src="https://www.googleadservices.com/pagead/conversion.js"> </script> <noscript> [img]https://www.googleadservices.com/pagead/conversion/1234567890/?value={/literal}{$orders[oi].order.subtotal}{literal}&label=Purchase&script=0[/img] </noscript> {/literal}

This adds 2 blank lines, and then adds the Google text under. Make sure to replace the "1234567890" above with your 10-digit Conversion ID number here as well.

8.) optional: step 7 will add the Google text on the left hand side of the page. If you want it centered, you can put the second half of the code into a table like this:

Code:
<TABLE border="0" width="100%"> <TR> <TD align="center" width="100%"> {literal} <script language="JavaScript" src="https://www.googleadservices.com/pagead/conversion.js"> </script> <noscript> [img]https://www.googleadservices.com/pagead/conversion/1234567890/?value={/literal}{$orders[oi].order.subtotal}{literal}&label=Purchase&script=0[/img] </noscript> {/literal} </TD> </TR> </TABLE>

Make sure to replace the "1234567890" above with your 10-digit Conversion ID number here as well.


That should do it! This works great for my v4.0.14 store, you may have to mess with it a bit if you see differences in the code. Here is one big copy/paste of my entire order_message.tpl so you can see it all in case that helps you:

Code:
{* $Id: order_message.tpl,v 1.32.2.1 2004/09/14 06:02:27 max Exp $ *} {if $this_is_printable_version eq ""} {capture name=dialog} <FONT class="ProductDetails">{$lng.txt_order_placed}</FONT> <FONT class="ProductDetails">{$lng.txt_order_placed_msg}</FONT> {/capture} {include file="dialog.tpl" title=$lng.lbl_confirmation content=$smarty.capture.dialog extra="width=100%"} {/if} {capture name=dialog} {section name=oi loop=$orders} {include file="mail/html/order_invoice.tpl" is_nomail='Y' products=$orders[oi].products giftcerts=$orders[oi].giftcerts userinfo=$orders[oi].userinfo order=$orders[oi].order} {if $active_modules.Interneka ne ""} { include file="modules/Interneka/interneka_tags.tpl" } {/if} {literal} <script language="JavaScript" type="text/javascript"> <!-- var google_conversion_id = 1234567890; var google_conversion_language = "en_US"; var google_conversion_format = "1"; var google_conversion_color = "FFFFFF"; if ({/literal}{$orders[oi].order.subtotal}{literal}) { var google_conversion_value = {/literal}{$orders[oi].order.subtotal}{literal}; } var google_conversion_label = "Purchase"; //--> </script> {/literal} {/section} {if $this_is_printable_version eq ""} <TABLE border="0" width="100%"> <TR> <TD align="left">{include file="buttons/button.tpl" button_title=$lng.lbl_print_invoice href="order.php?mode=invoice&orderid=`$orderids`" target="preview_invoice"}</TD> <TD align="right">{include file="buttons/button.tpl" button_title=$lng.lbl_continue_shopping style="button" href="home.php"}</TD> </TR> </TABLE> <TABLE border="0" width="100%"> <TR> <TD align="center" width="100%"> {literal} <script language="JavaScript" src="https://www.googleadservices.com/pagead/conversion.js"> </script> <noscript> [img]https://www.googleadservices.com/pagead/conversion/1234567890/?value={/literal}{$orders[oi].order.subtotal}{literal}&label=Purchase&script=0[/img] </noscript> {/literal} </TD> </TR> </TABLE> {/if} {/capture} {include file="dialog.tpl" title=$lng.lbl_invoice content=$smarty.capture.dialog extra="width=100%"}


Hope some of you find this helpful.
Brian
__________________
X-Cart Gold v4.0.18 [unix]
- Easy Checkout module
- ezUpsell module
- CDSEO module

X-Cart Gold v4.1.11 [unix]
***38,000+ active products!
- CDSEO module
- Address Book module
- Reorder module
- Smart Search module

X-Cart Gold v4.4.2 [unix]
- in development now!
Reply With Quote