This is an old revision of the document!


type:
integration
supports-foxycart-version-from:
2.0
system:
Google Adwords
name:
Google Adwords
description:
Integrate Google Adwords with your FoxyCart receipt
tags:
Google, Adwords
date:
2015-10-01

Google Adwords

Please note: The code on this page is submitted by members of the FoxyCart community, and may not verified by FoxyCart.com LLC in any way, shape, or form. Please double check the code before installing. If you need help with it please post in our forum, but if we cannot offer assistance (due to unfamiliarity with this particular system or language) we apologize in advance.

Installation

Step 1: Get your Google Adwords code

Follow the steps detailed on this page for getting your Google Adwords integration code. For step 6 in part 1 on that page, select the varying values option. For step 14 in part 1, select “Save instructions and tag”, which will download a text file to your computer.

Within the downloaded text file will be a snippet of code that looks like this:

<!-- Google Code for Your Website Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = XXXXXXXXX;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "aAbB1234cCdD5678";
var google_conversion_value = 10.00;
var google_conversion_currency = "USD";
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/XXXXXXXXX/?value=10.00&amp;currency_code=USD&amp;label=aAbB1234cCdD5678&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

Step 2: Customise the Adwords code

Using the code snippet you downloaded (and ensure you use the code you downloaded and not the example code pasted above), make the following changes:

  1. At the start of the code snippet, add {% if first_receipt_display %}
  2. At the end of the snippet, add {% endif %}
  3. Replace the line var google_conversion_value = 10.00; with var google_conversion_value = {{ total_order }};
  4. Replace the line var google_conversion_currency = 'USD'; with var google_conversion_currency = '{{ locale_info.int_curr_symbol|trim }}';
  5. Replace the part of the link that is value=10.00 with value={{ total_order }}
  6. Replace the part of the link that is currency_code=USD with currency_code={{ locale_info.int_curr_symbol|trim }}

Note parts 3 and 4 above may be a different number as the value - depending on what you entered when configuring the Adwords code.

With these changes made, you should have a snippet that looks like this:

{% if first_receipt_display %}
<!-- Google Code for Your Website Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = XXXXXXXXX;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "aAbB1234cCdD5678";
var google_conversion_value = {{ total_order }};
var google_conversion_currency = "{{ locale_info.int_curr_symbol|trim }}";
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/XXXXXXXXX/?value={{ total_order }}&amp;currency_code={{ locale_info.int_curr_symbol|trim }}&amp;label=aAbB1234cCdD5678&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
{% endif %}

Step 3: Add the code to your FoxyCart store configuration

Navigate to your store's FoxyCart administration, and to the “Configuration” section. Within the “Cart” section, check the “Add custom header and footer code to your templates” option if it isn't already, and add your code to the “Footer” text area.

Site Tools