user9528659
user9528659

Reputation:

How to pass multiple variables in GA Events?

In Google Analytics we can pass value as by document

https://developers.google.com/analytics/devguides/collection/analyticsjs/events

How to pass multiple variables at the same time instead of 2 calls?

onclick="ga('send', 'event', 'favorite', 'type','a');"
onclick="ga('send', 'event', 'favorite', 'id',100);"

I would like to pass both in only 1 call. How to do it?

Upvotes: 1

Views: 1678

Answers (1)

faridghar
faridghar

Reputation: 1515

If you want to pass more information/context about an event, your best bet would be to make use of hit-scoped custom dimensions. In your specific case, you would define two hit-scoped custom dimensions in GA (type and id). Once these are defined, they will each be assigned an index. Then in your tracking code, you would simply do the following:

ga('set', 'cd1', 'La');
ga('set', 'cd2', '100');
ga('send', 'event', 'favorite');

You would then be able to use your custom dimensions either as secondary dimensions in the standard Google Analytics reports or in custom reports.

You are allowed a maximum of 20 custom dimension in Google Analytics standard (the free version).

Upvotes: 3

Related Questions