By visiting our site, you agree to our privacy policy regarding cookies, tracking statistics, etc.

proper noun logo blue
  • Content Marketing
    • SEO Articles
    • Pillar Content
    • Website Content
    • Content Briefs
  • Off-Page
    • Managed Outreach
  • Optimization
    • Content Optimization
    • Technical SEO
  • Verticals
    • Ecommerce SEO Services
    • SaaS SEO Services
    • Enterprise Business SEO
    • Local SEO Services
  • Case Studies
  • Support
The Roadmap
Book A Demo
Adding Google AdWords Conversion Tracking To A Magento Website
November 5, 2021by adamUncategorized

Adding Google AdWords Conversion Tracking To A Magento Website

Spending money advertising with Google AdWords can make or break your e-commerce website, so it’s very important that you have accurate and up to date conversion tracking in place.  Many e-commerce website platforms and e-commerce content management systems make this easy to do, however with Magento, it requires a bit more work on the template side. In this tutorial we’ll cover how you can quickly set that up with a couple of lines of simple PHP and no need for any extensions.

First, start by opening up your success page template, or the success.phtml template within your theme. This file will be located at /app/design/frontend/YOUR THEME/template/checkout/success.phtml.  If you can’t find the file there, look inside the base/default directory and you should be able to find it there.

Next, login to Google AdWords and under the “Tools” tab, you will click “Conversions”.  Find the conversion you are trying to track, for example a purchase, and open it up, you will then see your conversion code on the next page.  Copy this conversion code and paste it in to your success.phtml template near the bottom of the page.  This code should look like this:

[code] <!– Google Code for Purchase/Sale Conversion Page –>
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = XXXXXXXXXX;
var google_conversion_language = "en";
var google_conversion_format = "1";
var google_conversion_color = "666666";
var google_conversion_label = "XXXXXXXXX";
var google_conversion_value = 1.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= 1.00&amp;currency_code=USD&amp;label=XXXXXXXXX&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
[/code]

You will notice that there are two sections that ask for a conversion value, but default to 1.00. This is what we will want to swap for dynamic code that will find the order subtotal and pass it to Google AdWords. To do this you’ll first need to include this PHP snippet to create a variable called subtotal.

[php] <?php
$order = Mage::getModel(‘sales/order’)->loadByIncrementId($this->getOrderId());
$subtotal = $order->getSubtotal();
?>
[/php]

Once you have this setup, you will then need to go through your conversion tag and replace the conversion value default of 1.00 with the following:

[php] <?php echo $subtotal ?>
[/php]

So when all is said and done, your final Google AdWords conversion tracking code should look like this:

[code] <!– Google Code for Purchase/Sale Conversion Page –>
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = XXXXXXXXXX;
var google_conversion_language = "en";
var google_conversion_format = "1";
var google_conversion_color = "666666";
var google_conversion_label = "XXXXXXXXX";
var google_conversion_value = <?php echo $subtotal ?>;
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=<?php echo $subtotal ?>&amp;currency_code=USD&amp;label=XXXXXXXXX&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
[/code]

Make sure to replace the default not only in the top section of the code, but also within the “img” tag at the bottom of the provided snippet. Once you have all of this in place, you can upload your success.phtml template to your FTP and then run a test by adding a product to cart, checking out, and verifying your purchase with Google Tag Manager.

Read More
Share
proper noun logo blue

Proper Noun is an SEO, digital growth, and content marketing agency located in Fort Lauderdale, FL.

Twitter Facebook-f Google-plus-g Pinterest-p Linkedin-in

Contacts

Our Offices
300 SW 1st Ave #155
Fort Lauderdale, FL 33301
Give Us A Call
(954)674-1258

Our Services

  • Content Marketing
  • Ecommerce SEO Services
  • Enterprise Business SEO
  • Managed Outreach
  • Technical SEO
  • Website Optimization

Our Company

  • Blog
  • Contact Us
  • Book A Demo
  • Case Studies
  • Article Writing
  • Website Directory

© 2022 Proper Noun. All Rights Reserved.

Proper Noun is a content marketing agency located in Fort Lauderdale, FL. Proper Noun provides managed content marketing campaigns and managed outreach campaigns for ecommerce businesses, saas products, law firms, real estate, enterprise businesses and much more. We also offer a la carte content creation services.

Markets We Serve

  • Ecommerce SEO
  • Enterprise SEO
  • International SEO
  • National SEO
  • Local SEO
  • B2B SEO
  • Whitelabel SEO
  • SEO Consulting
  • SEO Reseller

Contacts



8 800 2563 123

  emil@yoursite.com

 27 Division St, New York, NY 10002, United States