CustomDimension send via ga('set',...)

2.3k views Asked by At

I have two buttons, to set gender. For each gender button I've set up a customDimension like ga('set', 'dimension1', 'male'); or ga('set', 'dimension1', 'female');

In the Javascript Console from FireBug I see that the ga() command is executed without errors. In GoogleAnalytics I have set a customDimension

Must I send this data specific via ga('send',...... or is this not needed??

If yes, which parameters do I have to set?

I can't see any received Data in GoogleAnalytics GUI and I have waited about 48 hours.

1

There are 1 answers

1
Eike Pierstorff On

Custom Metrics and Dimensions must always be sent with an interaction hit, else they will not get recorded.

In addition, fields set with ga('set'... must be followed by an interaction hit - "set" in this case literally means "set this field for subsequent use in interaction hits". The difference between using set and passing the custom dimensions via the configuration object of an interaction hit (pageviews, events etc) is that "set" will affect all following hits while passing the custom dimension/metric as a parameter to a hit will only affect that specific hit.

So if you use ga('set', 'dimension1', 'male') and you have after that one pageview and two events the dimension will be recorded three times (not so much a problem with custom dimensions, potentially a big problem with custom metrics).

If you do instead:

ga('send', 'pageview', {
  'dimension1':  'male'
});

the dimension will be send only once.

But no matter how you do it, the data will only be sent along hit data, so you need a pageview, event or transaction if you want any results.