Post by fido-x » Thu Mar 31, 2016 9:13 pm

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.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by jacquesy » Thu Apr 07, 2016 4:07 am

Thank you for this update, I had this very problem and it has resolved it perfectly.

Cheers

Newbie

Posts

Joined
Wed Apr 06, 2016 5:12 am

Post by coolbreeze86 » Thu Apr 14, 2016 7:15 pm

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.

New member

Posts

Joined
Sun Mar 17, 2013 4:36 am

Post by wbizs » Thu Apr 14, 2016 8:04 pm

many thanks, fixed by your method.

Newbie

Posts

Joined
Thu Apr 14, 2016 8:26 am

Post by chaneytw » Thu Apr 28, 2016 7:45 pm

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

Newbie

Posts

Joined
Thu Apr 28, 2016 7:17 pm

Post by GottaRun » Fri May 06, 2016 5:19 am

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?

Current OpenCart Version 2.1.0.1


Newbie

Posts

Joined
Fri May 06, 2016 5:11 am
Location - Ireland

Post by moneycarlo » Fri May 06, 2016 2:30 pm

try adding this bug fix mod. It appears to resolve the multi store google analytics issue.
https://github.com/pekka2/OpenCart-Migr ... .ocmod.xml

Active Member

Posts

Joined
Wed Sep 28, 2011 3:40 am

Post by dragonfly-ie » Mon May 30, 2016 6:59 am

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)

“May the best day of your past be the worst day of your future.”


User avatar
New member

Posts

Joined
Sat Nov 09, 2013 2:31 am
Location - 52°N 7°37'W

Post by nasirkhan » Tue Jul 26, 2016 3:08 pm

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.

Nasir Khan Saikat
http://nasirkhn.com


Newbie

Posts

Joined
Tue Jul 26, 2016 2:17 pm
Location - Dhaka, Bangladesh

Post by coolbreeze86 » Fri Jul 29, 2016 2:20 am

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.

New member

Posts

Joined
Sun Mar 17, 2013 4:36 am

Post by straightlight » Fri Jul 29, 2016 4:09 am

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

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by labeshops » Fri Jul 29, 2016 6:05 am

There is a free vqmod that fixes this in the extensions store too.

Running Opencart v2.2 with multi-stores from http://www.labeshops.com which has links to all my stores.

Image


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by kamarad » Wed Sep 21, 2016 6:25 pm

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?

Newbie

Posts

Joined
Sun Feb 14, 2016 6:09 am

Post by fido-x » Fri Sep 23, 2016 11:13 am

You're looking in the WRONG file. You should be looking in admin/controller/analytics/google_analytics.php.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by ahpongccx » Thu Nov 10, 2016 4:43 pm

It's fixed , thanks dude.

New member

Posts

Joined
Fri Jul 22, 2016 3:10 pm
Who is online

Users browsing this forum: No registered users and 10 guests