Page 1 of 1

Error when adding Google analytics tracking code [solved]

Posted: Fri May 27, 2016 2:21 am
by dragonfly-ie
Using original theme and clean oc v2.2.

> Extensions > Analytics > Google Analytics Code enabled
When entering code:

Code: Select all

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-xxxxxxxx', 'auto');
  ga('send', 'pageview');
</script>
I get error msg upon saving:
Notice: Undefined index: store_id in .../admin/controller/analytics/google_analytics.php on line 13
Warning: Cannot modify header information - headers already sent by (output started at .../admin/controller/startup/error.php:34) in .../system/library/response.php on line 12
??? ??? ??? ???

In google real-time traffic reports, analytics_test seems to be working. Why the error? or is it a bug?

Re: Error when adding Google analytics tracking code

Posted: Sun May 29, 2016 12:43 am
by chipmaestro
I'm also getting this... anyone know of a solution?

Re: Error when adding Google analytics tracking code

Posted: Sun May 29, 2016 1:47 am
by straightlight

Re: Error when adding Google analytics tracking code

Posted: Sun May 29, 2016 12:10 pm
by fido-x
WRONG SOLUTION!

By removing the store_id, you can only set the Google Analytics for the default store.

Use the solution posted at viewtopic.php?f=191&t=160302. Not only does it provide the fix to the problem, it also explains why the problem exists in the first place.

Re: Error when adding Google analytics tracking code

Posted: Mon May 30, 2016 4:30 am
by straightlight
fido-x wrote:
WRONG SOLUTION!

By removing the store_id, you can only set the Google Analytics for the default store.

Use the solution posted at viewtopic.php?f=191&t=160302. Not only does it provide the fix to the problem, it also explains why the problem exists in the first place.
In both situations, as explained on my topic is that the store_id could not be found anywhere else on that file which means that variable was running on its own rather than relying on an origin. Removing the request post or removing the store_id would of worked both ways since you explained on your topic that the post has to be removed on anyhow. Which means, my topic does not necessarily leads to a wrong solution but rather an alternate solution.

Re: Error when adding Google analytics tracking code

Posted: Mon May 30, 2016 6:50 am
by dragonfly-ie
Thanks, lads.
Both are good solutions.
Since I don't multi-store the alternate solution is doing the trick for me.
Much appreciated. 8)

Re: Error when adding Google analytics tracking code [solved

Posted: Tue Jul 26, 2016 3:10 pm
by nasirkhan
tried both solutions but the Google analytics code is not visible on my website.

Re: Error when adding Google analytics tracking code [solved

Posted: Wed Sep 21, 2016 6:26 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?