Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

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

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #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
  #2  
Old 12-29-2005, 09:07 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default

Nice summary Always nice to find ALL the info in one place!
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 12-29-2005, 02:52 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Moved to Completed Custom Mods & Templates.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #4  
Old 04-07-2006, 02:06 PM
  markcrobinson's Avatar 
markcrobinson markcrobinson is offline
 

Senior Member
  
Join Date: Jan 2006
Posts: 180
 

Default How about Signup?

Any idea how to add the adwords tracking for signups?
__________________
X-Cart version 4.4.5
PHP 5.1.6
GD bundled (2.0.28 compatible)
MySQL server 5.0.45
MySQL client 5.0.45
Web server Apache/2.2.3 (CentOS)
Operation system Linux
Perl not found
XML parser (expat) found
X-Cart directory size 316 Mb
Reply With Quote
  #5  
Old 04-07-2006, 02:45 PM
 
patrick24601 patrick24601 is offline
 

Senior Member
  
Join Date: Mar 2006
Location: Oklahoma City, OK
Posts: 183
 

Default

I just tried adding this to my cart. All of the code shows up but I don't see the little google graphic on my checkout page. Does that mean it is not functioning?
__________________
---
Patrick Allmond
Xcart 4.0.18
Now on a dedicated linux box
Reply With Quote
  #6  
Old 04-07-2006, 03:05 PM
  markcrobinson's Avatar 
markcrobinson markcrobinson is offline
 

Senior Member
  
Join Date: Jan 2006
Posts: 180
 

Default It shows up on mine

It shows up after I complete a checkout.. at the bottom of the page.
__________________
X-Cart version 4.4.5
PHP 5.1.6
GD bundled (2.0.28 compatible)
MySQL server 5.0.45
MySQL client 5.0.45
Web server Apache/2.2.3 (CentOS)
Operation system Linux
Perl not found
XML parser (expat) found
X-Cart directory size 316 Mb
Reply With Quote
  #7  
Old 04-07-2006, 03:07 PM
 
patrick24601 patrick24601 is offline
 

Senior Member
  
Join Date: Mar 2006
Location: Oklahoma City, OK
Posts: 183
 

Default

Hmmm... all I see is the regular print invoice and continue shipping options. nothing at all related to google.
__________________
---
Patrick Allmond
Xcart 4.0.18
Now on a dedicated linux box
Reply With Quote
  #8  
Old 04-07-2006, 03:19 PM
  markcrobinson's Avatar 
markcrobinson markcrobinson is offline
 

Senior Member
  
Join Date: Jan 2006
Posts: 180
 

Default If you want to post the code, I'll look at it.

I'll take a look if you like.
__________________
X-Cart version 4.4.5
PHP 5.1.6
GD bundled (2.0.28 compatible)
MySQL server 5.0.45
MySQL client 5.0.45
Web server Apache/2.2.3 (CentOS)
Operation system Linux
Perl not found
XML parser (expat) found
X-Cart directory size 316 Mb
Reply With Quote
  #9  
Old 04-07-2006, 08:27 PM
 
patrick24601 patrick24601 is offline
 

Senior Member
  
Join Date: Mar 2006
Location: Oklahoma City, OK
Posts: 183
 

Default

Any idea why some of the google code has no data where the xcart objects should be? My checkout code appears as:

Code:
<script language="JavaScript" src="https://www.googleadservices.com/pagead/conversion.js"> </script> <noscript> [img]https://www.googleadservices.com/pagead/conversion/12345678/?value=&label=Purchase&script=0[/img] </noscript>

should I not have something for the 'value=' querystring ?

Code:
{literal} <script language="JavaScript" src="https://www.googleadservices.com/pagead/conversion.js"> </script> <noscript> [img]https://www.googleadservices.com/pagead/conversion/1068741053/?value={/literal}{$orders[oi].order.subtotal}{literal}&label=Purchase&script=0[/img] </noscript> {/literal}
__________________
---
Patrick Allmond
Xcart 4.0.18
Now on a dedicated linux box
Reply With Quote
  #10  
Old 04-08-2006, 04:45 AM
  markcrobinson's Avatar 
markcrobinson markcrobinson is offline
 

Senior Member
  
Join Date: Jan 2006
Posts: 180
 

Default ID Code?

I'm a little concerned about the line that contains:
pagead/conversion/12345678/?
This is not your Google ID #.
For mine, I went to the advords site and got the code from the code generator there, then split up the code according to this post.
Although in the code you sent me privately, your codes seem to be OK.

Could this be the problem?

In the code you sent me privately, you read

Code:
{ include file="modules/Interneka/interneka_tags.tpl" } {/if} {*** Google Analytics conversion tracking ***} {include file="g_analytics.tpl" products=$orders[oi].products order=$orders[oi].order} {*** ************************************************************************** ***} {*** Google Adwords Conversion tracking ***} {literal}
...


Code:
</script> {/literal} {*** ************************************************************************** ***} {/section} {if $this_is_printable_version eq ""}

In my code (that works) the
Code:
{/section}

statement comes BEFORE the google code.

like so..

Code:
{ include file="modules/Interneka/interneka_tags.tpl" } {/if} {/section} {literal} <script language="JavaScript" type="text/javascript"> <!--

Mark Robinson
HandicappedPets.com
__________________
X-Cart version 4.4.5
PHP 5.1.6
GD bundled (2.0.28 compatible)
MySQL server 5.0.45
MySQL client 5.0.45
Web server Apache/2.2.3 (CentOS)
Operation system Linux
Perl not found
XML parser (expat) found
X-Cart directory size 316 Mb
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:22 PM.

   

 
X-Cart forums © 2001-2020