{"id":25,"date":"2017-04-26T04:29:58","date_gmt":"2017-04-26T04:29:58","guid":{"rendered":"http:\/\/www.analyticsbook.org\/?page_id=25"},"modified":"2021-02-19T01:30:44","modified_gmt":"2021-02-19T01:30:44","slug":"google-analytics-custom-dimensions-and-custom-metrics","status":"publish","type":"page","link":"https:\/\/www.analyticsbook.org\/google-analytics-custom-dimensions-and-custom-metrics\/","title":{"rendered":"Google Analytics Custom Dimensions and Custom Metrics"},"content":{"rendered":"
\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tGordon Choi
\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAuthor<\/p>\n
<\/p>\n
By default, Google Analytics makes built-in dimensions and metrics available. However, if some dimensions and metrics are not available, you can create custom dimensions and\/or custom metrics.<\/p>\n
Once the custom dimensions and\/or custom metrics are created, you can use them to collect and analyze data that Google Analytics did not automatically track by default.<\/p>\n
Each dimension and\/or metric has a scope. Some examples:<\/p>\n
<\/ins><\/p>\n Below are the steps when using custom dimensions and custom metrics.<\/p>\n Under Add Custom Dimension,<\/p>\n Under Add Custom Metric,<\/p>\n <\/ins><\/p>\n A hit is a user’s interaction with your mobile website that results in data being sent to Google Analytics. Examples of hits include:<\/p>\n A user on your mobile website can send one or more hits, and value of a custom dimension is sent once per hit.<\/p>\n A session is a group of hits recorded for a user in a given time period. When a custom dimension is created with session scope, its value is applied to all the hits in a current session. A custom dimension\u2019s value is sent once per session during a user\u2019s session on your mobile website.<\/p>\n A session expires after 30 minutes of a user’s inactivity on your mobile website or at midnight (i.e. 00h00). A session can also expire when a user returns to your mobile website through a different campaign.<\/p>\n When a user visits your mobile website for the first time, Google Analytics sets a new cookie on his \/ her web browser. A session is created for each user\u2019s visit to your mobile website. For each user\u2019s session:<\/p>\n For a custom dimension with user scope, a user’s lifetime on your mobile website can last or expire.<\/p>\n A custom dimension’s value is sent once per user during a user\u2019s lifetime on your mobile website.<\/p>\n Assume your mobile website is a hotel booking website which has different level of pages:<\/p>\n Assume the specific hotel detail page (with id h00011) is a hotel located in city Beijing.<\/p>\n Assume the specific hotel detail page (with id h00012) is a hotel located in city Shanghai.<\/p>\n Assume the specific hotel detail page (with id h00013) is a hotel located in city Shenzhen.<\/p>\n In this case, you will need Google Analytics to report on sessions by Beijing hotels, sessions by Shanghai hotels, sessions by Shenzhen hotels, etc. Not a single standard Google Analytics report can provide such information.<\/p>\n You can set up a custom dimension to track sessions per city.<\/p>\n Under Add Custom Dimension,<\/p>\n The next step is you will have to add an additional code to the Universal Analytics version of your standard Google Analytics tracking code. The format of the additional code is:<\/p>\n On all the web pages which contain a Beijing hotel, assign ‘hotel-beijing’ as value.<\/p>\n One the web page, the entire Google Analytics tracking code will become:<\/p>\n The sequence of each line of code is important. The line of code that sets the custom dimension has to be defined before the page view is sent.<\/p>\n For web pages with a Shanghai hotel, assign \u2018hotel-shanghai\u2019.<\/p>\n For web pages with a Shenzhen hotel, assign \u2018hotel-shenzhen\u2019.<\/p>\n On all other web pages that do not require tracking sessions by hotel city, you will still use the standard tracking code without changes. Or refer to Google Analytics Tracking Codes<\/a>.<\/p>\n Assume you have allowed time for Google Analytics to collect data into your newly implemented custom dimension.<\/p>\n From any Google Analytics report that has Second Dimension available for selection, click to expand the Second Dimension drop-down. Your newly created \u201chotelcity\u201d custom dimension should appear under Custom Dimensions.<\/p>\n Now you can use your custom dimensions in your Google Analytics reports. Example:<\/p>\n <\/ins><\/p>\n <\/p>\n Content on Gordon Choi’s Analytics Book is licensed under the CC Attribution-Noncommercial 4.0 International license.<\/em><\/p>\n Gordon Choi’s Other Books: <\/p>\n <\/p>\n [elementor-template id=”764″]\t\t<\/p>\n Copyright 2016-2021 www.AnalyticsBook.org<\/p>\n","protected":false},"excerpt":{"rendered":" How To Add Custom Dimensions and Custom Metrics In Google Analytics? Gordon Choi Author Chapter 06 – Google Analytics Custom Dimensions and Custom Metrics Custom Dimensions Custom Metrics Steps to Create and Use Custom Dimensions and\/or Custom Metrics Create a New Custom Dimension Create a New Custom Metric Scope of Hit for Custom Dimensions Scope […]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"elementor_canvas","meta":{"footnotes":""},"yoast_head":"\nSteps to Create and Use Custom Dimensions and\/or Custom Metrics<\/h2>\n
\n
Create a New Custom Dimension<\/h2>\n
Go to Admin -> Custom Definitions -> Custom Dimensions -> + New Custom Dimension<\/pre>\n
\n
Create a New Custom Metric<\/h2>\n
Go to Admin -> Custom Definitions -> Custom Metrics -> + New Custom Metric<\/pre>\n
\n
Scope of Hit for Custom Dimensions<\/h2>\n
\n
Scope of Session for Custom Dimensions<\/h2>\n
Scope of User for Custom Dimensions<\/h2>\n
\n
\n
Custom Dimension Example<\/h2>\n
Homepage: http:\/\/www.example.com\/\nHotel search result page per city: http:\/\/www.example.com\/hotel-list\/beijing\/\nHotel detail page: http:\/\/www.example.com\/hotel-detail\/h00011<\/pre>\n
http:\/\/www.example.com\/hotel-detail\/h00011<\/pre>\n
http:\/\/www.example.com\/hotel-detail\/h00012<\/pre>\n
http:\/\/www.example.com\/hotel-detail\/h00013<\/pre>\n
Step 1: Configuration<\/h3>\n
Go to Admin -> Custom Definitions -> Custom Dimensions -> + New Custom Dimension<\/pre>\n
\n
Step 2: Code Implementation<\/h3>\n
ga('set', 'dimension1', 'value');<\/pre>\n
ga('set', 'dimension1', 'hotel-beijing');<\/pre>\n
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\nm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n})(window,document,'script','\/\/www.google-analytics.com\/analytics.js','ga');\nga('create', 'UA-XXXXXXXX-Y', 'auto');\nga('set', 'dimension1', 'hotel-beijing');\nga('send', 'pageview');\n<\/pre>\n
ga('create', 'UA-XXXXXXXX-Y', 'auto');\nga('set', 'dimension1', 'hotel-beijing');\nga('send', 'pageview');<\/pre>\n
ga('set', 'dimension1', 'hotel-shanghai');<\/pre>\n
ga('set', 'dimension1', 'hotel-shenzhen');<\/pre>\n
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\nm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n})(window,document,'script','\/\/www.google-analytics.com\/analytics.js','ga');\nga('create', 'UA-XXXXXXXX-Y', 'auto');\nga('send', 'pageview');\n<\/pre>\n
Steps 3 & 4: Data Collection and Reporting<\/h3>\n
\n
\nPrevious Chapters<\/h4>\n
\n
Next Chapters<\/h4>\n
\n
\n
\n
The China Mobile SEO Book<\/a>
Mobile Website Book<\/a>
<\/em><\/p>\n