0
votes

Ater googling for an hour or 2 I give up. While executing the code below, this is the result of the Chrome Google Analytics plugin. I have activated Ecommerce in the GA-admin settings for this ID. Pagevies are executed perfectly and visible using ga('send', 'pageview') but a purchase action fails...

  • analytics_debug.js:10 Initializing Google Analytics.
  • analytics_debug.js:10 Loading resource for plugin: ec
  • analytics_debug.js:10 Loading script: "http://www.google-analytics.com/plugins/ua/ec.js"
  • analytics_debug.js:10 Running command: ga("create", "UA-23554312-1", "auto")
  • analytics_debug.js:10 Creating new tracker: t0
  • analytics_debug.js:10 Auto cookieDomain found: "none"
  • analytics_debug.js:10 Running command: ga("require", "ec")
  • analytics_debug.js:10 Waiting on require of "ec" to be fulfilled.
  • analytics_debug.js:10 Registered new plugin: ga(provide, "render", Function)
  • analytics_debug.js:10 Running command: ga("require", "ec")
  • analytics_debug.js:10 Waiting on require of "ec" to be fulfilled.
  • analytics_debug.js:10 Executing Google Analytics commands.
  • analytics_debug.js:10 Registered new plugin: ga(provide, "ec", Function)
  • analytics_debug.js:10 Running command: ga("require", "ec")
  • analytics_debug.js:10 Plugin "ec" intialized on tracker "t0".
  • analytics_debug.js:10 Running command: ga("ec.setAction", "purchase", {id: "362", affiliation: "Besteld winkel Barendrecht", revenue: "2.95", shipping: "0", tax: "0.17"})
  • analytics_debug.js:10 Command ignored. Unknown target: undefined

I really do not know what is wrong with this code and it ends with 'unknown target'. Does anybody have a clue what I am missing here?

<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-23554312-1', 'auto');
ga('require', 'ec');
ga('ec.setAction', 'purchase', {
'id': '362',
'affiliation': 'Besteld winkel Barendrecht',
'revenue': '2.95',
'shipping': '0',
'tax': '0.17'
});
</script>

Thanx for your time, Regards, Marc Verkade

1
And as a last step, post a pageview since data to GA is only send after an event! ga('send', 'pageview');Marc Verkade
Very good read you can find at optimizesmart.com/…Marc Verkade

1 Answers

0
votes

This looks like a straightforward syntax error.

Change ec.setAction to ec:setAction and you should be OK.