bruincub
bruincub

Reputation: 61

Google Analytics Global Site Tag Custom Parameters

According to Google's gtag.js guide, it seems like we're able to define custom parameters. However, when using the code examples, only the Event Action gets populated. The Event Label is recorded in Google Analytics as "(not set)" and the Event Category as "general".

Code Example from developers.google.com:

gtag('event', 'video_play', {
  'video_title': 'My promotional video',
  'duration': '01:32'
});

It's also interesting to note that I cannot figure out how to show custom parameters as the columns in Google Analytics seem to be statically set to "Event Category", "Event Action", and "Event Label". These correspond to the default keys of "event_category", "event_action", and "event_label". Using these keys sends the values correctly. The following code works:

    gtag('event', 'redirect', {
    'event_category': 'Announcements',
    'event_label': '/announcements/index.jsp',

Has anyone gotten custom parameters to work or is this a feature that hasn't been implemented yet in gtag.js? Is there additional configuration needed that I may have missed?

Upvotes: 5

Views: 958

Answers (1)

Open SEO
Open SEO

Reputation: 1712

If you you were thinking of GA Custom Dimensions and Custom Metrics, yes it is available in the gtag.js / Global Site Tag syntax, see https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets in the form of a Map of CD indexes and attribute explicit names, followed by setting values to explicit attribute names.

for example

// Maps 'dimension2' to 'age'.
gtag('config', 'GA_MEASUREMENT_ID', {
  'custom_map': {'dimension2': 'age'}
});

// Sends an event that passes 'age' as a parameter.
gtag('event', 'age_dimension', {'age': 55});

See also https://developers.google.com/analytics/devguides/collection/gtagjs/migration#custom_dimensions_and_metrics

However, gtag.js is a wrapper to make analytics.js easier to implement by hiding some its complexity. If you are used to analytics.js, keep using it, you get more control on its behavior. Or move to GTM, it's way more flexible.

Upvotes: 0

Related Questions