Can't find variable: ga

1,921 views
Skip to first unread message

David Anson

unread,
May 21, 2015, 2:29:03 AM5/21/15
to google-analyti...@googlegroups.com
AFAIK I have followed the instructions for setting up ecommerce tracking on my website but on my test page the console is showing me the error:

ReferenceError: Can't find variable: ga
global codearticle:850

I have checked that the page is using the analytics.js script and not the old ga.js

My javascript code is being built up using PHP and produces the following code on my test page:

<script>


ga
('require', 'ecommerce');
ga
('ecommerce:addTransaction',{
 
'id': 'emmanewton',
 
'affiliation': 'Online',
 
'revenue': '29.95',
 
'shipping': '0',
 
'tax': '0'});
ga
('ecommerce:addItem', {
 
'id': 'emmanewton',
 
'name': 'CID',
 
'sku': 'CID',
 
'category': 'software',
 
'price': '29.95',
 
'quantity': '1'});
ga
('ecommerce:send');


</script>

Any ideas greatly appreciated.

TIA

David

Philip Walton

unread,
May 21, 2015, 12:42:14 PM5/21/15
to David Anson, google-analyti...@googlegroups.com
If the error you're getting is that the `ga` variable doesn't exist, then somehow you're either not using the analytics.js snippet or you've implemented it incorrectly. Without seeing the code, it's impossible to know.

--
You received this message because you are subscribed to the Google Groups "google-analytics-analyticsjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-analytics-ana...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Philip Walton

unread,
May 27, 2015, 12:22:01 PM5/27/15
to David Anson, google-analyti...@googlegroups.com
On Fri, May 22, 2015 at 1:54 AM, David Anson <davida...@gmail.com> wrote:

The site has been built using Joomla and a template from RocketTheme.  It is now supposed to be operating using analytics.js and not ga.js and if you do a search on the code of the test Thank You page http://www.adv.co.uk/component/content/article?id=54&cartID=EmmaNewton22189318 the only script that is found is analytics.js.  Furthermore my Google Analytics has been working perfectly ever since the change over to analytics.js so I am quite puzzled.

David, if you look at the source of the page you linked to, you'll notice that the analytics.js snippet is using the variable "__gaTracker" instead of the typical "ga" variable.

So you can either update all your plugin code statements to use "__gaTracker" or you can update whatever code is loading analytics.js to use the "ga" varaible.
Reply all
Reply to author
Forward
0 new messages