Skip to main content

Google Universal Analytics Broken

More
11 years 10 months ago - 11 years 10 months ago #178218 by Dorgo
-- 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
Code:
'HikaShop Google Analytics plugin','plugin','hikashopanalytics','system',0,1,1,0,'','{\"universal_analytics\":\"1\"
Code:
<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
Code:
if($this->params->get('use_universal', 0)) {


Was this even remotely tested or reviewed?
Last edit: 11 years 10 months ago by Dorgo.

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

More
11 years 10 months ago - 11 years 10 months ago #178262 by Jerome
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.
Last edit: 11 years 10 months ago by Jerome.

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

More
11 years 10 months ago - 11 years 10 months ago #178439 by Dorgo
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
Code:
preg_replace("#<script type=\"text/javascript\">(?:(?!<script).)*'https://ssl' : 'http://www'\) \+ '\.google-analytics\.com.*</script>#siU", '', $body);
change to
Code:
$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,
Code:
ga('require', 'displayfeatures'); ga('require', 'linkid', 'linkid.js');
Last edit: 11 years 10 months ago by Dorgo.

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

More
11 years 10 months ago #178495 by Jerome
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:
Code:
$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");';
Code:
ga("send", "pageview");'.$extra_required.'

GA part:
Code:
$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]);';
Code:
var _gaq = _gaq || [];'.$extra_required.'
(plus the options in the XML file)

Regards,

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

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

Time to create page: 0.157 seconds
Powered by Kunena Forum