AdWords
1.5K members online now
1.5K members online now
Use AdWords conversion tracking and reporting to measure your results. Have a question about Google Analytics? Post it here, on the Google Analytics Community!
Guide Me
star_border
Reply

Setting up AdWords Conversion Tracking with Magento

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi there,

 

I've been trying to figure out what the best way would be to implement AdWords Conversion Tracking with dynamic values on the Magento platform. I would rather implement it without using an extensions

 

Below is the code that I put on the success page, however, the goal seems to be breaking at:

var google_conversion_value =

Resulting in the AdWords goal never being verified.

 

Any help would be much appreciated!

 

<!-- Google Code for Sale: Transactions Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = xxxx;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "xxxx";
var google_conversion_value = <?php echo $this->getOrder()->getSubtotal() ?>;
var google_conversion_currency = "CAD";
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/xxx/?value=<?php echo $this->getOrder()->getSubtotal() ?>&amp;currency_code=CAD&amp;label=xxx;guid=ON&amp;script=0"/>
</div>
</noscript>

1 Expert replyverified_user
Marked as Best Answer.
Solution
Accepted by topic author Michael R
March 2016

Re: Setting up AdWords Conversion Tracking with Magento

Top Contributor
# 2
Top Contributor
Hi Michael R,

Yes, there is a problem with the script if no value is provided.

First, check to be sure this is correct: $this->getOrder()->getSubtotal(). It seems this returns and empty string. I found this article on the correct way to do this:
http://www.codexpedia.com/magento/get-last-order-details-from-checkout-session-in-magento/

In the case that an empty string could be valid , I add quotes around the value:

var google_conversion_value =" <?php echo $this->getOrder()->getSubtotal() ?>";

Best of Luck!

Pete
petebardo -- Deadhead doing AdWords