Page 1 of 1

Google Analytics in 2.2.0.0

Posted: Thu Mar 31, 2016 9:13 pm
by fido-x
I notice that Daniel has attempted to provide proper multi-store support for Google Analytics. I've got news for you - it doesn't work!

In admin/controller/analytics/google_analytics.php at line 13, we have:

Code: Select all

$this->model_setting_setting->editSetting('google_analytics', $this->request->post, $this->request->get['store_id']);
In theory, this should work. However, since the store_id is never passed through as a "get" value when the form is posted, the setting will only be updated for the default store.

The reason can be found at line 62, where we have:

Code: Select all

$data['action'] = $this->url->link('analytics/google_analytics', 'token=' . $this->session->data['token'], true);
If we change this to:

Code: Select all

$data['action'] = $this->url->link('analytics/google_analytics', 'token=' . $this->session->data['token'] . '&store_id=' . $this->request->get['store_id'], true);
the store_id will then be passed back when the form is posted and the setting will be updated for the relevant store.

However, there is a further problem when retrieving the values from the setting table.

Line 71 reads:

Code: Select all

$data['google_analytics_code'] = $this->config->get('google_analytics_code');
and line 77 reads:

Code: Select all

$data['google_analytics_status'] = $this->config->get('google_analytics_status');
In the administration, "$this->config->get()" will only ever return the value that has been set for the default store.

Changing lines 71 to:

Code: Select all

$data['google_analytics_code'] = $this->model_setting_setting->getSettingValue('google_analytics_code', $this->request->get['store_id']);
and line 77 to:

Code: Select all

$data['google_analytics_status'] = $this->model_setting_setting->getSettingValue('google_analytics_status', $this->request->get['store_id']);
will fix the issue.

Re: Google Analytics in 2.2.0.0

Posted: Thu Apr 07, 2016 4:07 am
by jacquesy
Thank you for this update, I had this very problem and it has resolved it perfectly.

Cheers

Re: Google Analytics in 2.2.0.0

Posted: Thu Apr 14, 2016 7:15 pm
by coolbreeze86
Hi,

Fatal error: Class 'Controlleranalyticsorggoogleanalytics' not found in /home/xxxx/public_html/vqmod/vqcache/vq2-system_storage_modification_system_engine_action.php on line 36

getting this as error.

Re: Google Analytics in 2.2.0.0

Posted: Thu Apr 14, 2016 8:04 pm
by wbizs
many thanks, fixed by your method.

Re: Google Analytics in 2.2.0.0

Posted: Thu Apr 28, 2016 7:45 pm
by chaneytw
Hi,thanks a lot ! it worked.
But there is another problem , my google analytics code always display on my page at left top side .
Everyone visit my site will see the code . Do you have any idea?
thank you very much

Re: Google Analytics in 2.2.0.0

Posted: Fri May 06, 2016 5:19 am
by GottaRun
I too have this problem with the analytics code being displayed. I have turned it back off for now. Would anyone have a solution or alternative guide to embedding it in the template or site code?

Re: Google Analytics in 2.2.0.0

Posted: Fri May 06, 2016 2:30 pm
by moneycarlo
try adding this bug fix mod. It appears to resolve the multi store google analytics issue.
https://github.com/pekka2/OpenCart-Migr ... .ocmod.xml

Re: Google Analytics in 2.2.0.0

Posted: Mon May 30, 2016 6:59 am
by dragonfly-ie
moneycarlo wrote:try adding this bug fix mod. It appears to resolve the multi store google analytics issue.
https://github.com/pekka2/OpenCart-Migr ... .ocmod.xml
Anyone tried this? Do we trust pekka2? 8)

Re: Google Analytics in 2.2.0.0

Posted: Tue Jul 26, 2016 3:08 pm
by nasirkhan
i tried the mentioned changes for my single store. After the changes the Google analytics code was saved successfully. but the problem is the code is not visible on the frontend.

Re: Google Analytics in 2.2.0.0

Posted: Fri Jul 29, 2016 2:20 am
by coolbreeze86
Hi any reply for this,

Fatal error: Class 'Controlleranalyticsorggoogleanalytics' not found in /home/xxxx/public_html/vqmod/vqcache/vq2-system_storage_modification_system_engine_action.php on line 36

getting this as error.

Re: Google Analytics in 2.2.0.0

Posted: Fri Jul 29, 2016 4:09 am
by straightlight
coolbreeze86 wrote:Hi any reply for this,

Fatal error: Class 'Controlleranalyticsorggoogleanalytics' not found in /home/xxxx/public_html/vqmod/vqcache/vq2-system_storage_modification_system_engine_action.php on line 36

getting this as error.
Hi, please read this FAQ regarding VQCache errors: http://forum.opencart.com/viewtopic.php?f=170&t=165657

Re: Google Analytics in 2.2.0.0

Posted: Fri Jul 29, 2016 6:05 am
by labeshops
There is a free vqmod that fixes this in the extensions store too.

Re: Google Analytics in 2.2.0.0

Posted: Wed Sep 21, 2016 6:25 pm
by kamarad
Hello

Those codes that you enter is not in my google_analytics.php file?

In my google_analytics.php fil are only following code:

<?php
class ControllerAnalyticsGoogleAnalytics extends Controller {
public function index() {
return html_entity_decode($this->config->get('google_analytics_code'), ENT_QUOTES, 'UTF-8');
}
}


Why is it here?

Can someone help me?

Re: Google Analytics in 2.2.0.0

Posted: Fri Sep 23, 2016 11:13 am
by fido-x
You're looking in the WRONG file. You should be looking in admin/controller/analytics/google_analytics.php.

Re: Google Analytics in 2.2.0.0

Posted: Thu Nov 10, 2016 4:43 pm
by ahpongccx
It's fixed , thanks dude.