javascriptgoogle-analyticsgoogle-tag-manageruniversal-analytics

Why do I get Unknown target error when attempting to send a Google Universal Analytics Event with javascript


I am attempting to send an event to Google Universal Analytics:

ga('send', {
    hitType: 'event',
    eventCategory: 'calculator-interaction',
    eventAction: 'click',
    eventLabel: 'calculate-button'
});

but I am getting the following error:

Running command: ga("send", [object Object])
analytics.js:31 Command ignored. Unknown target: undefined

The Google Universal Analytics is being included in the page via Google Tag Manager if that makes a difference?


Solution

  • Ga needs a tracker object to send commands. Are you using ga('create', 'UA-XXXXX-Y', 'auto')?

    If yes, you might be specifying a named tracker instead. In this case, you will need to target it specifically by calling ga('name_of_the_tracker.send', options)