Google Universal Analytics Broken

  • Posts: 51
  • Thank you received: 1
10 years 9 months ago #178218

-- HikaShop version -- : 2.3.4
-- Joomla version -- : 2.5.27
-- PHP version -- : 5.3.29
-- Browser(s) name and version -- : N/A

The parameter you are storing in the database is universal_analytics

'HikaShop Google Analytics plugin','plugin','hikashopanalytics','system',0,1,1,0,'','{\"universal_analytics\":\"1\"
<param name="universal_analytics" type="radio" default="0" label="Use universal analytics" description="Use or not the new API of google analytics (ga.js or universal.js)">
			<option value="0">No</option>
			<option value="1">Yes</option>
		</param>

Instead, you are checking for use_universal in the plugin
if($this->params->get('use_universal', 0)) {


Was this even remotely tested or reviewed?

Last edit: 10 years 9 months ago by Dorgo.

Please Log in or Create an account to join the conversation.

  • Posts: 26264
  • Thank you received: 4043
  • MODERATOR
10 years 9 months ago #178262

Hi,

Well, it has not.
I asked the HikaShop team to test my development but I guess that they include them partially and without test it.
Please replace "universal_analytics" by "use_universal" in the XML.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Last edit: 10 years 9 months ago by Jerome.

Please Log in or Create an account to join the conversation.

  • Posts: 51
  • Thank you received: 1
10 years 9 months ago #178439

Thanks Jerome, did you write the plugin for hikashop?

The regex that strips out the existing snippet needs updating:

plugins/system/hikashopanalytics/hikashopanalytics.php:84

preg_replace("#<script type=\"text/javascript\">(?:(?!<script).)*'https://ssl' : 'http://www'\) \+ '\.google-analytics\.com.*</script>#siU", '', $body);
change to
$body = preg_replace("#<script type=\"text/javascript\">(?:(?!<script).)*('https://ssl' : 'http://www'\) \+ '\.|window,document,'script','//www\.)google-analytics\.com.*</script>#siU", '', $body);

also, it would be nice to be able to handle extra features without hacking the plugin eg,
ga('require', 'displayfeatures');
ga('require', 'linkid', 'linkid.js');

Last edit: 10 years 9 months ago by Dorgo.

Please Log in or Create an account to join the conversation.

  • Posts: 26264
  • Thank you received: 4043
  • MODERATOR
10 years 9 months ago #178495

Hi,

I just update existing plugin in order to add the support of "universal".
It was some kind of "POC", something I made at 3am and because I do not have any GA account (or Universal) I couldn't test it.

Thanks for the modification about the regex ; I updated the plugin.
I also added two new options for the modules (linkid and displayfeatures).
linkid will have a support for GA and UA ; displayfeatures is only available for UA.

UA part:

			$extra_required = '';
			if($this->params->get('module_displayfeatures', 0))
				$extra_required .= "\r\n" . 'ga("require", "displayfeatures");';
			if($this->params->get('module_linkid', 0))
				$extra_required .= "\r\n" . 'ga("require", "linkid", "linkid.js");';
ga("send", "pageview");'.$extra_required.'

GA part:
			$extra_required = '';
			if($this->params->get('module_linkid', 0))
				$extra_required .= "\r\n" .
'var pluginUrl = "//www.google-analytics.com/plugins/ga/inpage_linkid.js";
_gaq.push(["_require", "inpage_linkid", pluginUrl]);';
var _gaq = _gaq || [];'.$extra_required.'
(plus the options in the XML file)

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum