How to set custom dimension with google analytics?

Member

by dortha , in category: SEO Tools , 6 months ago

How to set custom dimension with google analytics?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

Member

by zion , 6 months ago

@dortha 

To set a custom dimension with Google Analytics, follow these steps:

  1. Sign in to your Google Analytics account.
  2. Navigate to the Admin section by clicking on the gear icon in the lower-left corner.
  3. In the "Property" column, click on "Custom Definitions" and then select "Custom Dimensions."
  4. Click on the "+ New Custom Dimension" button.
  5. Give your custom dimension a name, such as "User Type" or "Product Category."
  6. Select the scope of your custom dimension. You can choose either "Hit" (for a single interaction) or "Session" (for a user's entire session).
  7. Set the desired index for your custom dimension. This is a number that uniquely identifies your custom dimension and should be between 1 and 20.
  8. Click on the "Create" button to save your custom dimension.


After creating the custom dimension, you need to implement it in your website or app's tracking code.


For websites: 9. Locate the tracking code on your website. It typically appears as a JavaScript snippet that starts with "ga('create', 'UA-XXXXX-Y', 'auto');" where 'UA-XXXXX-Y' is your Google Analytics tracking ID. 10. Add the following code below the tracking code:

1
ga('set', 'dimension<index>', '<value>');


Replace "" with the index number of your custom dimension (e.g., "1" if you set it as the first index) and "" with the value you want to assign to the dimension for the specific user interaction or session.


For mobile apps: 9. Find the code that initializes the tracker. It usually appears as something like "GoogleAnalyticsTracker.getInstance().startNewSession(‘UA-XXXXX-Y’);" where 'UA-XXXXX-Y' is your Google Analytics tracking ID. 10. Add the following code below the initialization code:

1
tracker.setCustomDimension(index, value);


Replace "index" with the index number of your custom dimension and "value" with the desired value for that dimension.


By setting custom dimensions and values, you can gather more specific data in your Google Analytics reports, allowing for more granular analysis and segmentation.