X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Google Adwords Conversion Tracking: a how-to on adding code (https://forum.x-cart.com/showthread.php?t=18895)

btomasie 12-27-2005 01:29 PM

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

balinor 12-29-2005 09:07 AM

Nice summary :) Always nice to find ALL the info in one place!

B00MER 12-29-2005 02:52 PM

:!: Moved to Completed Custom Mods & Templates.

markcrobinson 04-07-2006 02:06 PM

How about Signup?
 
Any idea how to add the adwords tracking for signups?

patrick24601 04-07-2006 02:45 PM

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?

markcrobinson 04-07-2006 03:05 PM

It shows up on mine
 
It shows up after I complete a checkout.. at the bottom of the page.

patrick24601 04-07-2006 03:07 PM

Hmmm... all I see is the regular print invoice and continue shipping options. nothing at all related to google.

markcrobinson 04-07-2006 03:19 PM

If you want to post the code, I'll look at it.
 
I'll take a look if you like.

patrick24601 04-07-2006 08:27 PM

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}


markcrobinson 04-08-2006 04:45 AM

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


All times are GMT -8. The time now is 02:46 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.