Zen Cart Logo
Forums / All Other Contributions/Addons / Easy Google Analytics vs google_conversion_currency

Easy Google Analytics vs google_conversion_currency

Views: 1,251

Results 1 to 1 of 1
8 Nov 2014, 5:39 PM
#1
enzo_ita avatar

enzo_ita

Zen Follower

Join Date:
Jul 2009
Posts:
402
Plugin Contributions:
0

Easy Google Analytics vs google_conversion_currency

Hi,
adwords experts were complainig about the code created by Easy Google Analytics.
They said that is has to be exactly like the one you can get from their site or they could not give assistance about crazy reports I get from adwords.
So I ventured in a mod to the file google_analytics.php included in the folder \includes\templates\your_template\google_analytics of the original file set of the plugin Easy Google Analytics by Numinix.
The code I came out with is

<?php
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                                       |
// +----------------------------------------------------------------------+
// | Portions Copyright (c) 2003 osCommerce                               |
// | Portions Copyright (c) 2004 zen-cart								  |
// | Portions Copyright (c) 2005-2006 Andrew Berezin					  |
// | Portions Copyright (c) 2006 Dayne Lasen							  |
// | Portions Copyright (c) 2007-2010 Eric Leuenberger					  |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.zen-cart.com/license/2_0.txt.                             |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to       |
// | [email protected] so we can mail you a copy immediately.          |
// +----------------------------------------------------------------------+
// | file: google_analytics.php, 2010/12/02							  	  |
// | Adds Google Analytics Capability to Zen Cart						  |
// | Version Information:  v1.2.4 2010.12.02							  |
// | Author: Eric Leuenberger - http://www.TheEcommerceExpert.com         | 
// | Mod by: enzo lipomi on 2014 08 11                                     |
// +----------------------------------------------------------------------+
//

if (GOOGLE_CONVERSION_ACTIVE == "Yes" && GOOGLE_ANALYTICS_ENABLED == "Enabled" && $_GET['main_page'] == FILENAME_CHECKOUT_SUCCESS) {
    if ($request_type == 'NONSSL') {
        $google_conversion_url             = "//www.googleadservices.com/pagead/conversion.js";
        $google_conversion_image_url     = "//www.googleadservices.com/pagead/conversion/";
    } else {
        $google_conversion_url             = "//www.googleadservices.com/pagead/conversion.js";
        $google_conversion_image_url     = "//www.googleadservices.com/pagead/conversion/";
    }
?>
<!-- mod by Enzo based on numinix Google Code for purchase Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
	var google_conversion_id =  <?php echo GOOGLE_CONVERSION_IDNUM; ?>;
	var google_conversion_language 	= "<?php echo GOOGLE_CONVERSION_LANG;  ?>";
	var google_conversion_format = "2";
	var google_conversion_color = "ffffff";
	var google_conversion_label = "<?php echo (GOOGLE_CONVERSION_LABEL != '' ? GOOGLE_CONVERSION_LABEL : 'purchase'); ?>";		
<?php
	if ($google_analytics['ot_total'] != "") ?>
	var google_conversion_value = <?php echo $google_analytics['ot_total']?>;
	<?php
} else {
?>
	var google_conversion_value = 1.00;
<?php
} 
?>
var google_conversion_currency = "<?php echo GOOGLE_CONVERSION_CURRENCY; ?>";
	var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="<?php echo $google_conversion_url; ?>"></script>
<noscript>
<?php
			$gen_img_url = $google_conversion_image_url . GOOGLE_CONVERSION_IDNUM . '/?value=' . (($google_analytics['ot_total'] != "") ? $google_analytics['ot_total'] : "1") .'&currency_code=' . GOOGLE_CONVERSION_CURRENCY . '&'
?>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="<?php echo $gen_img_url; ?>label=<?php echo (GOOGLE_CONVERSION_LABEL != '' ? GOOGLE_CONVERSION_LABEL : 'purchase'); ?>&guid=ON&script=0"/>
</div>
</noscript>
<!-- end Google Code for purchase Conversion Page -->

It seems to work nicely and give a cleaner snippet.
The only thing that is needed to do (and I am not able to to do it modding the installer of the plugin) is to create manually the field GOOGLE_CONVERSION_CURRENCY in the configuration table of the data base.
Once done that in the admin page under the configuration of Easy Google Analytics it will be needed to input the three digits of the currency of your site. May be that is is also needed to create a multiple currency system but that goes way beyond my programming capability.

ciao ciao from Italy
enzo