frankl Posted October 9, 2003 Share Posted October 9, 2003 Google Adwords has a great new tool, this is part of the email I got: New: Free conversion tracking tool Conversion tracking is the latest addition to our suite of Google AdWords reporting tools. This feature allows you to track how many ad clicks convert to purchases, sign-ups, page views, and leads - for free. You'll get AdWords conversion data right down to the keyword level in your reports, information that can help you better measure your return on investment (ROI) and make smarter online advertising decisions See it here: Google AdWords FAQ: Conversion Tracking I want to implement the option to track sales, how can I pass the order total to the checkout success page and then pass that to the Google code? They have PHP instructions in the User Guide. Cheers from Down Under osCommerce user since 2003! Link to comment Share on other sites More sharing options...
wizardsandwars Posted October 9, 2003 Share Posted October 9, 2003 It might be easier just to install the OSC affilliate program, and then sign up Google as an affiliate. The OSC affiliate program give all kinds of stats including clicks and conversions, and can track customers that don't purchase right away, or leave, bookmark, and then come back. ------------------------------------------------------------------------------------------------------------------------- NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit. If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help. Link to comment Share on other sites More sharing options...
frankl Posted October 9, 2003 Author Share Posted October 9, 2003 Actually, it would be easier through Google as all you have to add to osC is a few lines of code, not a whole mod, because Google does all of the above too, but matches it with keywords as well. Anyway, there's no point in getting into a debate as to which is better, because the Affiliate mod is perfect for those who need it, I just need to know which code to use to implement Google's conversion tool. Can anyone help? osCommerce user since 2003! Link to comment Share on other sites More sharing options...
frankl Posted October 10, 2003 Author Share Posted October 10, 2003 OK, this will track the order totals: Open catalog/checkout_success.php and just before the first closing mark in the file - ?> - add the following lines of code... //added for Google $Query = "select sum(value) as total_value from " . TABLE_ORDERS_TOTAL . " where class != 'ot_total' and orders_id = '" . $HTTP_GET_VARS['order_id'] . "'"; $result = tep_db_query($Query); $row = tep_db_fetch_array($result); $Total = $row["total_value"]; Then go to the Google Adwords setup section, choose the Purchase/Sale conversion type while going through the Customized Conversion Tracking path. Insert the string <? echo $Total ?> into the ?(Optional) Enter variable? field and press Refresh Code to generate the final tracking code. Copy this code and paste it into catalog/checkout_success.php. I put it just before the line <!-- body_text_eof //-->, and don't forget to put <td> before the code snippet and </td> at the end of the code snippet. Works great! osCommerce user since 2003! Link to comment Share on other sites More sharing options...
CodeConfused Posted October 10, 2003 Share Posted October 10, 2003 Hi frankl, Your solution is great!!! Unfortunately, I have been trying for hours to implement the same code, but haven't had much success... Somehow, I can't get the $Total to take a value, it always stays blank... Is there any chance you could paste your code for the entire page below (of course with the google id xxx-ed out :P ? It would be so much appreciated! :D Greetings, Dan Link to comment Share on other sites More sharing options...
CodeConfused Posted October 11, 2003 Share Posted October 11, 2003 never mind... just got it all figured out :) i hadn't exactly followed your instructions on where to place the php code that fetches the order total... now i put it in the place where you say it belongs, and -- it works perfectly :P thanks, dan Link to comment Share on other sites More sharing options...
matbennett Posted October 24, 2003 Share Posted October 24, 2003 The above code did not work on my store until I changed the query to be as follows: $Query = "select sum(value) as total_value from " . TABLE_ORDERS_TOTAL . " where class != 'ot_total' and orders_id = '" . $orders['orders_id'] . "'"; Not entirely sure why, but I think that this could be down to using the WorldPay payment module (didn't care enough to look once it was working!). Thought it worth mentioning here in case anyone else had a problem. Link to comment Share on other sites More sharing options...
Guest Posted November 16, 2003 Share Posted November 16, 2003 Thanks frank and mat. I implemented this and it works a charm. I had to use the later query provided by mat. cheers Link to comment Share on other sites More sharing options...
Guest Posted September 28, 2005 Share Posted September 28, 2005 OK, this will track the order totals: Open catalog/checkout_success.php and just before the first closing mark in the file - ?> - add the following lines of code... //added for Google $Query = "select sum(value) as total_value from " . TABLE_ORDERS_TOTAL . " where class != 'ot_total' and orders_id = '" . $HTTP_GET_VARS['order_id'] . "'"; $result = tep_db_query($Query); $row = tep_db_fetch_array($result); $Total = $row["total_value"]; Then go to the Google Adwords setup section, choose the Purchase/Sale conversion type while going through the Customized Conversion Tracking path. Insert the string <? echo $Total ?> into the ?(Optional) Enter variable? field and press Refresh Code to generate the final tracking code. Copy this code and paste it into catalog/checkout_success.php. I put it just before the line <!-- body_text_eof //-->, and don't forget to put <td> before the code snippet and </td> at the end of the code snippet. Works great! Thank you so very much!!! It works great!!!! Since you solved this problem, is there a way to only get the sub-total (minus s/h fees, taxes, etc) instead of the total? I really appreciate your fix and I do not mean to be rude in anyway but I thought I would try asking. Link to comment Share on other sites More sharing options...
Marc_J Posted November 28, 2005 Share Posted November 28, 2005 Thank you so very much!!! It works great!!!! Since you solved this problem, is there a way to only get the sub-total (minus s/h fees, taxes, etc) instead of the total? I really appreciate your fix and I do not mean to be rude in anyway but I thought I would try asking. I'm attempting this just now, it's hard to test as there's a 24 hour delay in Conversion Tracking with Google at the moment, but I reckon this will work: - Change the query to this: - //added for Google $Query = "select sum(value) as total_value from " . TABLE_ORDERS_TOTAL . " where class != 'ot_subtotal' and orders_id = '" . $HTTP_GET_VARS['order_id'] . "'"; $result = tep_db_query($Query); $row = tep_db_fetch_array($result); $Total = $row["total_value"]; Should return the order subtotal, before any shipping and taxes are added....I think. I'm going to try it anyway! A quick question, if anyone knows: - I've now got the javascript part of Google's code as this: - <script language="JavaScript" type="text/javascript"> <!-- var google_conversion_id = xxxxxxxxxx; var google_conversion_language = "en_GB"; var google_conversion_format = "1"; var google_conversion_color = "FFFFFF"; if (1.0) { var google_conversion_value = <? echo $Total ?>; } var google_conversion_label = "Purchase"; //--> </script> But what about the link in the noscript part? It's currently: - <noscript> <img height=1 width=1 border=0 src="http://www.googleadservices.com/pagead/conversion/xxxxxxxxxx/?value=1.0&label=Purchase&script=0"> </noscript> Would <noscript> <img height=1 width=1 border=0 src="http://www.googleadservices.com/pagead/conversion/xxxxxxxxxx/?value=<? echo $Total ?>&label=Purchase&script=0"> </noscript> work? Link to comment Share on other sites More sharing options...
Marc_J Posted November 28, 2005 Share Posted November 28, 2005 Scrap the second part of my post above, I let Google generate it for me again :) Link to comment Share on other sites More sharing options...
Marc_J Posted November 28, 2005 Share Posted November 28, 2005 My Subtotal query above was wrong, returned a value too high. Should be:- //added for Google $Query = "select sum(value) as total_value from " . TABLE_ORDERS_TOTAL . " where class = 'ot_subtotal' and orders_id = '" . $HTTP_GET_VARS['order_id'] . "'"; $result = tep_db_query($Query); $row = tep_db_fetch_array($result); $Total = $row["total_value"]; Worked for me :) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.