Skip to content
Snippets Groups Projects
Commit 132f0957 authored by Laurent's avatar Laurent
Browse files

Google analytics: fix analytics id extraction for new kind of GA scripts

parent 3de63f56
Branches
Tags
3 merge requests!2080Sandbox detach zf from storm,!2061Master,!1992Google analytics: fix analytics id extraction for new kind of GA scripts
Pipeline #278 passed with stage
in 11 minutes and 10 seconds
- ticket #52069 : correction de la récupération du Google Analytics ID pour les nouveaux scripts Google Analytics
\ No newline at end of file
......@@ -60,8 +60,10 @@ class Class_AdminVar_JsStat {
protected function _getGoogleAnalyticsId() {
$script = Class_AdminVar::get('JS_STAT');
preg_match_all("/setAccount[\', \n\t]+\'([^\']+)\'/i", $script, $matches);
return isset($matches[1][0]) ? $matches[1][0] : '';
preg_match_all("/(UA|MO)-[0-9]+-[0-9]/", $script, $matches);
return (isset($matches[0][0]))
? $matches[0][0]
: '';
}
......
......@@ -59,6 +59,27 @@ class Class_WebService_WebAnalyticsClientInstanciationWithVarGoogleAnalyticsAndN
class Class_WebService_WebAnalyticsClientInstanciationWithVarGoogleAnalyticsUsingGACreateTest extends Storm_Test_ModelTestCase {
public function setUp() {
parent::setUp();
Class_AdminVar::newInstanceWithId('JS_STAT', ['valeur' => "['_setaccount', 'a('create', 'UA-41754005-1', 'auto'); "]);
Class_AdminVar::newInstanceWithId('NOM_DOMAINE', ['valeur' => ""]);
$this->_web_analytics_client = new Class_WebService_Analytics_Client();
}
/** @test */
public function trackerAccountIdShouldBeUA_41754005_1() {
$this->assertEquals('UA-41754005-1', $this->_web_analytics_client->getTrackerAccountId());
}
}
class Class_WebService_WebAnalyticsClientInstanciationWithVarGoogleAnalyticsAndDomainNameTest extends Storm_Test_ModelTestCase {
public function setUp() {
parent::setUp();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment