Bvweijen
Bvweijen

Reputation: 73

Universal Analytics not working correctly

I'm updating the old analytics to Universal Analytics, but i'm having problems.

<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','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXXXX-X', 'website.com');
  ga('send', 'pageview');

</script>   

That's is the new code i pasted in my head file. But when i use de Analytics debugger (for Chrome) and i run a command like:

ga("send", "event", "navigation", "Click", "Home");

I get a error like this (in debugger):

Command ignored. Unknown target: undefined

I'm getting realtime data in analytics, so i know that the code is working for simple tracking. Event tracking is the problem.

Can somebody help me?

Upvotes: 2

Views: 759

Answers (1)

Jakub Kriz
Jakub Kriz

Reputation: 1529

Command ignored. Unknown target: undefined

This mean that your tracker is not initialized correctly or it is not initialized and you are trying to send data on them.

Problem

Problem should be ga('create', 'UA-XXXXXXX-X', 'website.com'); where you set website.com The question is: Are your events fired from same domain? This should be equal to document.location.hostname.

Testing

For testing, try it with auto parameter as cookieDomain. If this works, focus your energy into cookieDomain area.

Other possibilities

Some people reach this issue in different was, try to learn from them:

Documentation

Upvotes: 2

Related Questions