Google Analytics Code Not Working - FIXED IN V3.3

Post Reply
rabika
Posts: 1
Joined: Fri Jul 05, 2013 11:01 am
Contact:

Google Analytics Code Not Working - FIXED IN V3.3

Post by rabika » Fri Jul 05, 2013 11:05 am

The google analytics code that comes with v2.11, does not seem to be recognized by google. Not sure whether this is because google changed something or whether there is a bug in phpauction.

Replacing the code in class/Core/PresentationData.php->getGoogleAnalyticsCode() with the one that google recommends (upon registration), seems to fix it
RABIKA

RWAP
Site Admin
Posts: 750
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: Google Analytics Code Not Working

Post by RWAP » Fri Jul 05, 2013 1:37 pm

I have moved this discussion to a new topic which is more relevent !

You are correct - the code being used in Enuuk is apparently no longer supported by google.

My class\Core\PresentationData.php now contains the following function:

Code: Select all

    static public function getGoogleAnalyticsCode(Core_Context $context)
    {
		$gaCode = '<script type="text/javascript">
		      var _gaq = _gaq || [];
		_gaq.push(["_setAccount", "UA-xxxxxxx-x"]);
		_gaq.push(["_trackPageview"]);

		(function() {
		  var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
		  ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
		  var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
		})();</script>';
        if(String::checkGoogleAnalytics($context->siteOptions['googleAnalyticsID'])){
            return str_replace('UA-xxxxxxx-x', $context->siteOptions['googleAnalyticsID'], $gaCode);
        }else{
            return '';
        }
    }

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest