Magento and Google Adwords conversion tracking

Featured Image

If you use Google Adwords advertising for your Magento web store, you will probably need this module. This module will be very useful, because Magento doesn’t have functionality for tracking Adowrds conversion. Feel free to download module and use it on personal responsibility. I’m using this module on web store without any problems.

You need to know that this module will track Adwords conversion over checkout/success page. At checkout/success page will be executed javascript (this is code of Block for checkout/success page):

< ?php
/**
*
* @category   Inchoo
* @package    Inchoo Google Adwords
* @author     Domagoj Potkoc, Inchoo Team
*/
class Inchoo_Adwords_Block_Block extends Mage_Core_Block_Abstract
{
 
public function __construct()
{
parent::__construct();
$this->setGoogleConversionId(Mage::getStoreConfig('adwordsmodule/inchoad/google_conversion_id'));
$this->setGoogleConversionLanguage(Mage::getStoreConfig('adwordsmodule/inchoad/google_conversion_language'));
$this->setGoogleConversionFormat(Mage::getStoreConfig('adwordsmodule/inchoad/google_conversion_format'));
$this->setGoogleConversionColor(Mage::getStoreConfig('adwordsmodule/inchoad/google_conversion_color'));
$this->setGoogleConversionLabel(Mage::getStoreConfig('adwordsmodule/inchoad/google_conversion_label'));
}
 
protected function _toHtml()
{
$html = "";
 
if(Mage::helper('inchoo_adwords')->isTrackingAllowed()){
 
$this->setAmount(Mage::helper('inchoo_adwords')->getOrderTotal());
$html .= '
<!-- Google Code for Purchase Conversion Page -->
<script type="text/javascript">
/* < ![CDATA[ */
var google_conversion_id = '.$this->getGoogleConversionId().';
var google_conversion_language = "'.$this->getGoogleConversionLanguage().'";
var google_conversion_format = "'.$this->getGoogleConversionFormat().'";
var google_conversion_color = "'.$this->getGoogleConversionColor().'";
var google_conversion_label = "'.$this->getGoogleConversionLabel().'";
var google_conversion_value = 0;
if ('.$this->getAmount().') {
google_conversion_value = '.$this->getAmount().';
}
/* ]]> */
</script>
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/'.$this-/>getGoogleConversionId().'/?value='.$this->getAmount().'&amp;amp;amp;amp;amp;label='.$this->getGoogleConversionLabel().'&amp;amp;amp;amp;amp;guid=ON&amp;amp;amp;amp;amp;script=0"/>
</div>
</noscript>';
}
 
return $html;
}
}
?>

Module has some config options which you need set over Magento admin section. Go to admin System -> Configure -> left tab: “Inchoo Extensions” -> Google Adwords.
You need set some data as: Google conversion id, Google conversion label and so on, if you use Adwords advertising I hope that you know this 🙂

Download Magento – Google Adwords module


About Domagoj Potkoc

Backend Developer

Domagoj is Magento Certified Developer who enjoys playing tennis after long hours in front of computer screen.

Read more posts by Domagoj / Visit Domagoj's profile

49 comments

  1. Not working on 1.9?
    Maybe because (like me) you’re using the RWD theme, and it’s not picking up the inchoo_google_adwords.xml layout file which is in app\design\frontend\default\default\layout ?
    Solution: copy inchoo_google_adwords.xml into your theme’s layout folder. Sorted.

  2. After we upgrade to magento 1.9 , we have stopped see any ecommerce conversion in analytics. Is the extension compatible with magento 1.9?

  3. am getting problem with this extension on magento 1.9 is it working on that platform.

  4. Hi, I install the module, setup it on the admin interface, cleaned up the magento cache and html cache, did a purchase on my onepagecheckout but the status on adwords still “not confirmed” any idea what is missing?

  5. Hi Installed the stuff and it works great, I got a doubt over this, please have a look and let me know if we can add this as an option if necessary.

    code var google_remarketing_only = false;

  6. We have installed the extentsion but you are refering to Google conversion id, Google conversion label which we have no clue what is – is the Conversion ID our adwords account number? and the label is equal to what?

  7. @Tom Currently, this extension only cares about the checkout success page, but it could be extended easily.

  8. Will this extension allow adding conversions for contact form uses or is it just for sales/purchases? Looks great by the way! Many thanks

  9. First thank you for this interesting post.
    I wanted just to add some comments on behalf the problems faced by some people :

    – Make sure to add the layout file to your theme folder.

    – To check the code in your success page, you may use firebug or Chrome developer tool. If you check it with a simple “view source code”, the page will be refreshed and redirected to your empty shopping card.

    – The code is not adapted to secure page. Means that if your success page is on HTTPS, Google links should be on HTTPS too.

    The code was tested on Magento 1.7 and it is working well.

  10. Hi, is this module working on Magento 1.7? I’ve implemented manually the code generated on my adwords account into success page, but depending of your payment module, the adwords code is called twice (some modules use iframes or something like that) and this is not good. I downloaded an extension for Chrome to check in real time if all Google tags on the current page you’re browsing are correct, or no. How can I make the google conversion code work only and only on success page, not on payment possible pages or iframes? Thanks man.

  11. I’m not able to get admin section to display all settings for that module (blank page) on Magento 1.4.1.1

  12. Works with 1.7.0.2 out of the box – only, if you’re using COMPILATION, remember to re-compile!! (I didn’t…)

  13. I’ve tried this on 1.7.0.2 and the tracking status of the conversion in Adwords never changes from Unverified. I’m using PayPal Express Checkout. Additionally, my Analytics Goal which has a Goal URL of /checkout/onepage/success never completes.

  14. Hi,
    Thanx for this module. It works for 1.7 also.
    Couple of things to remind: if you do a view source on the success page, you won’t find the results. Please check http://stackoverflow.com/questions/12450659/google-adwords-convertion-tracking-in-magento-not-visible-in-view-source

    Also, I’ve adapted the helper Data.php file, so that the subtotal_incl_tax is returned instead of the subtotal (necessary in my situation, could be different of course for other people).

    Thanks again,

    Tom
    (not the same Tom as above 🙂 )

  15. I was getting the same Inchoo_Adwords_Helper_Data’ error and I followed the advice on this post and disabled the compiler.

    Now I get the following error
    Parse error: syntax error, unexpected ‘}’, expecting ‘{‘ in /home/ABCD/public_html/shop/app/code/community/LUKA/GoogleAdWords/Helper/Data.php on line 39

    Please let me know what needs to be done.

  16. Hi,

    the tip with Compiler disable seems to work. Unfortunately I got another problem. When I select the extension in the back end I got a “access denied” error

    What can I do ?

  17. Rui, I tried calling and emailing these guys. They don’t answer. Turns out that Analytics Plus (Fooman) extension has adwords conversion built in. The only trick is that you have to edit the file ga-conversion.phtml var google_conversion_label = “Purchase”;

    simply replace Purchase with the actual value that Google gives in their code snippet. It works, good luck.

  18. I’m also interested in setting up Adwords conversion tracking and would appreciate if you can answer Robbie questions above so I would be able to instal it in my site.

  19. I’m really interested in setting up adwords conversion tracking and I feel retarded for asking this, but I’m really confused.

    1) Where do go to download the “module”
    2) What does this code have to do with the module? are yo supposed to update the module with this code?

  20. Update: you probably have your magento Compiler enabled. This has given me some problems before…

    If you disable it it works.

  21. Hi,

    I got the same error when I try to install the modul:
    Fatal error: Class ‘Inchoo_Adwords_Helper_Data’ not found in …../Mage.php on line 520

    Any updates on this issue?

  22. Hi, I installed the plugin on magento version 1.4.2.0 and when i go to system>configuration I get the following error:
    Fatal error: Class ‘Inchoo_Adwords_Helper_Data’ not found in /web/n3xt/mugman.be/www/app/Mage.php on line 520

    Any idea how to fix this? All help will be appreciated!

  23. Thanks for this extension! Do I need to enter a value in my AdWords-account settings to track the actual revenue? AdWords-suggest to enter a quanity to track the number of sales or an average ammount to give an average, but it’s also possible to track the actual sales with a specific value isn’t it?

  24. Hi, great plugin! Well almost, I have the same problem as others – the tracking doesn’t work and when I check the page source it simply isn’t there.

    It is as if the layout/inchoo_adwords.xml file is just ignored maybe?

  25. Sorry for the multiple comments, but I have the same issue as Craig. When checking the page source, I don’t see any adwords code. Only my analytics code.

  26. False alarm! I had to actually disable the cache. I’m not exactly sure why since I tried refreshing the cache, logging out and back in. Anyway, it’s up now. I’ve been having a hard time having my conversions read.

    One last question: in Adwords, do I need to put the URL as https://…./success or http? I currently have it as https but I read that adwords won’t read that. Also, my success page doesn’t use the secure urls for css and js files. Is this normal? If not, is there a way to add the secure urls to the success page? All my other checkout pages work fine.

    You guys are doing a fantastic job!

  27. Is this for Magento 1.4 only? I’m running 1.3.0 and definitely need something like this. I can’t seem to get it to work for 1.3.0. When I click on the tab, I just see a blank white body and all my left tabs disappear. Please let me know if there is a solution to 1.3.0

  28. Sorry, what I meant more specifically in my last post is that the checkout/success page did not have the code in it after the order was placed.

  29. hello,

    Same here – after successful installation of your extension, I placed a live order in the store and the Adwords tracking code is not there. Would love for this to work, please reply.

    thanks,
    Craig

  30. Hello —

    Thanks for the module. It looks great. I was able to install it properly and enter in the proper values it’s expecting under Configuration, however the google code doesn’t appear in the success page, just the standard . Any ideas on what to do?

    Thanks again,
    Carlos

  31. Thanks, I’m sure we’ll put this to use next year.

    We’re also after a Magento – Adwords extension that uses the Adwords API to assist the creation and management of large campaigns. I don’t see any module like this in Magento Connect which is surprising. Does anyone know of any kind of Adwords API module for Magento?

  32. Just what I was looking for, thanks a lot.

    I had my own implementation, but without the admin interface, making it somewhat hard to maintain for the non-techies on the project 😉

  33. Hi,

    Thanks for checking in.

    I thought I did that before w/out success but I did it again (did “Refresh” action on all Cache Types and then clicked the “Flush Magento Cache” button) and it’s all good now. Had some wonkiness initially (blank in the main content area when I clicked on the “Google Adwords” tab) but after logging out and back in it seemed ok.

    I’ll put in my variables and see if the tracking works over the next few days. Thanks for your help!

    -Don

  34. Hi Domagoj,

    Thanks for putting this together. I tried installing this module by copying all the files over in the same directory structure using my FTP client and everything seems to be copied properly over, but I don’t see the Inchoo tab in System-> Configuration. I’m using Magento CE 1.4.1.1 — is the module compatible with this version?

    thanks,
    Don

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.