1
votes

I am working on a SaaS application, where I let user(s) to use their own google analytics account for tracking their site.

While tracking, I also wants to take benefit of custom dimensions. It is not possible to telling/educating each client(most of them are non-technical) about "how to create custom dimension/metric using Google Analytic Interface".

Is there any way, that I can create custom dimension using code. something like

ga('<command>','<dimension name>', '<index>', '<scope>')  
1
couldn't find anything to start with. All the documents refers to creating custom dimension with interface. - Sakhawat
This is from Google. You must setup the custom dimensions in via the interface first. developers.google.com/analytics/devguides/collection/… - colecmc
@colecmc yes you are right, but any work around, anything.. that i could create dimension using API. - Sakhawat
Not to my knowledge. Maybe check out google tag manager. See if GTM did anything sneaky to work around this. - colecmc

1 Answers

0
votes

You can create Custom Dimensions in the Google Analytics Management API, see: https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/customDimensions/insert

There is some example code for working with the api here: https://github.com/google/google-api-java-client-samples/tree/master/analytics-cmdline-sample

Good luck :)