Search code examples
c#apigoogle-analyticse-commercegoogle-analytics-api

Detect if Google Analytics eCommerce Tracking is enabled via Google Analytics API


By default, Google Analytics disables eCommerce Tracking.

Is it possible to check, via the Google Analytics Data Export API, whether or not e-Commerce Tracking is enabled in the account in question?


Solution

  • As far as I can tell, there is no way to detect solely if it is turned on.

    You can checkout the XML responses that the Google Analytics APIs provide: http://ga-api-http-samples.googlecode.com/svn/trunk/src/ ; it does not appear that any of them expose the actual setting.

    The one way that I've detected it in one of my apps is to simply open up the date range as far back as possible and check the count transactions (Metric: ga:transactions, no Dimension necessary). If that's greater than 0, eCommerce Transactions are enabled. However, if transactions are equal to 0, it could mean that eCommerce is enabled but not in active use.

    Fun fact: You can actually use eCommerce Tracking without enabling it; Google Analytics will collect and preserve the data; once you enable it, all of your priorly sent eCommerce data will be there. Bizarrely, it seems that the option to enable or disable eCommerce Tracking is really just a UI setting, rather than a real option.