Search code examples
javascriptangulargoogle-analyticsgoogle-tag-managergoogle-analytics-sdk

Seeing custom Tag Manager keys in Google Analytics?


This youtube demo inclues a page_path event key. I tried including the same thing in this stackblitz demo:

  uaClick1() {
    console.log("CLICKED UA 1")
    gtag('event', 'MY_BUTTON_1_CLICK', {
      'page_path': "in",
      'event_category': 'BUTTON_CLICK',
      'event_label': 'UA Click 1',
      'value': 'Some custom value 1'   })
  }

However I don't see the custom key showing up in Google Analytics:

enter image description here

Is it possible to add custom keys as shown? Also IIUC the value key is standard, but I don't see that either. Is there some other place I should be looking?


Solution

  • no, you can't pass custom data in that way. first, you'll need to set up custom dimension/metrics and then use specific mappings as shown in the docs:

    gtag('config', 'GA_MEASUREMENT_ID', {
      'custom_map': {'dimension1': 'event_label'}
    });
    
    //...
    
    gtag('event', 'MY_BUTTON_1_CLICK', {
        'page_path': "in",
        'event_category': 'BUTTON_CLICK',
        'event_label': 'UA Click 1',
        'value': 334   }) // has to be numerical value