{"id":130,"date":"2011-07-08T21:18:44","date_gmt":"2011-07-08T21:18:44","guid":{"rendered":"http:\/\/www.evermoredevnotes.com\/?p=130"},"modified":"2011-07-08T21:18:44","modified_gmt":"2011-07-08T21:18:44","slug":"adding-google-adwords-sale-conversion-tracking-code-to-a-magento-site","status":"publish","type":"post","link":"https:\/\/www.evermoretechnologies.com\/blog\/2011\/07\/adding-google-adwords-sale-conversion-tracking-code-to-a-magento-site\/","title":{"rendered":"Adding Google Adwords sale conversion tracking code to a magento site."},"content":{"rendered":"<p>Google Adwords conversion tracking can be a useful tool. \u00a0Some of the data can be found and or linked in from Google Analytics, but it&#8217;s not always as reliable or as easy to read as straight sale conversion tracking.<\/p>\n<p>To add sale conversion follow these steps.<br \/>\n1. Open the template file at<br \/>\n\/app\/design\/frontend\/{interface}\/{layout}\/checkout\/success.phtml<br \/>\nAdd this code to get the sale amount:<\/p>\n<p>[code language=&#8221;php&#8221;]<br \/>\n&lt;?php<br \/>\n$order_details = Mage::getModel(\u2018sales\/order\u2019)-&gt;loadByIncrementId(Mage::getSingleton(\u2018checkout\/session\u2019)-&gt;getLastRealOrderId());<br \/>\n$google_saleamt = $order_details-&gt;subtotal;<br \/>\n?&gt;<br \/>\n[\/code]<\/p>\n<p>2.  Get your adwords conversion tracking code from your adwords account and paste it in the bottom of the template file.  We want to modify if so if we have a value, we pass that value to Google Adwords, so modify it so it looks like this:<br \/>\n[code language=&#8221;javascript&#8221;]<br \/>\n&lt;!\u2013 Google Code for Sale Conversion Page \u2013&gt;<br \/>\n&lt;script type=\u201dtext\/javascript\u201d&gt;<br \/>\n&lt;!\u2013<br \/>\nvar google_conversion_id = 0987654321;<br \/>\nvar google_conversion_language = \u201cen\u201d;<br \/>\nvar google_conversion_format = \u201c3\u2033;<br \/>\nvar google_conversion_color = \u201cffffff\u201d;<br \/>\nvar google_conversion_label = \u201cKFKFKFKFKFKF\u201d;<br \/>\nvar google_conversion_value = 0;<br \/>\nif (&lt;?php echo $adwords_saleamt; ?&gt;) {<br \/>\ngoogle_conversion_value = &lt;?php echo $google_saleamt; ?&gt;;<br \/>\n}<br \/>\n\/\/\u2013&gt;<br \/>\n&lt;\/script&gt;<br \/>\n&lt;script type=\u201dtext\/javascript\u201d src=\u201dhttps:\/\/www.googleadservices.com\/pagead\/conversion.js\u201d&gt;<br \/>\n&lt;\/script&gt;<br \/>\n&lt;noscript&gt;<br \/>\n&lt;div style=\u201ddisplay:inline;\u201d&gt;<br \/>\n&lt;img height=\u201d1\u2033 width=\u201d1\u2033 style=\u201dborder-style:none;\u201d alt=\u201d&quot; src=\u201dhttps:\/\/www.googleadservices.com\/pagead\/conversion\/0987654321\/?value=150&amp;amp;label=KFKFKFKFKFKF&amp;amp;guid=ON&amp;amp;script=0\u2033\/&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;\/noscript&gt;<br \/>\n[\/code]<\/p>\n<p>Note the only new lines are below the setting of google_conversion_value to 0 where we add:<br \/>\n[code language=&#8221;javascript&#8221;]<br \/>\nif (&lt;?php echo $google_saleamt; ?&gt;) {<br \/>\ngoogle_conversion_value = &lt;?php echo $google_saleamt; ?&gt;;<br \/>\n}<br \/>\n[\/code]<\/p>\n<p>The source for this post is: http:\/\/www.noamdesign.com\/blog\/magento-how-to-setup-google-adwords-conversion-tracking\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google Adwords conversion tracking can be a useful tool. \u00a0Some of the data can be found and or linked in from Google Analytics, but it&#8217;s not always as reliable or&#8230; <a href=\"https:\/\/www.evermoretechnologies.com\/blog\/2011\/07\/adding-google-adwords-sale-conversion-tracking-code-to-a-magento-site\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,22],"tags":[],"_links":{"self":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/130"}],"collection":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=130"}],"version-history":[{"count":0,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/130\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.evermoretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}