{"id":413,"date":"2016-11-19T15:51:08","date_gmt":"2016-11-19T11:51:08","guid":{"rendered":"https:\/\/optimizationup.com\/?p=413"},"modified":"2016-11-19T15:51:08","modified_gmt":"2016-11-19T11:51:08","slug":"expose-client-user-id-google-analytics","status":"publish","type":"post","link":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/","title":{"rendered":"Expose Client &#038; User ID in Google Analytics"},"content":{"rendered":"<p><span style=\"color: #99cc00;\"><a style=\"color: #99cc00;\" href=\"https:\/\/optimizationup.com\/tag\/analytics\/\">Google Analytics<\/a><\/span> uses a unique identifier\u00a0to determine if two hits belong to the same user, the unique identifier associated with that particular user must be sent with each hit. GA accomplishes this via <strong>Client ID<\/strong> which is a unique, randomly generated string that gets stored in the browser&#8217;s cookies, so subsequent visits to the same site can be associated with the same user.<\/p>\n<p style=\"text-align: left;\">Here is an example of a client id:\u00a0<em><strong>15625772458.54738899. <\/strong><\/em>As you can see,<em><strong>\u00a0<\/strong><\/em>It&#8217;s a\u00a0combination of unique random number and the first time stamp.<\/p>\n<p>Using<strong> cookies<\/strong> allow analytics to identify unique users across browsing sessions, but it cannot identify unique users across different browsers or devices. If your site has its own authentication system, you can use the <strong>User ID<\/strong> feature, in addition to the client ID, to more accurately identify a user across all the devices they use to access your site.<\/p>\n<p>By default, <span style=\"color: #99cc00;\"><a style=\"color: #99cc00;\" href=\"https:\/\/optimizationup.com\/tag\/analytics\/\">Google Analytics<\/a><\/span> offers a report that lets you isolate and examine individual rather than aggregate user behavior via Client ID or User ID (if you have it enabled). The report can be found under the &#8220;User Explorer&#8221; tab:-<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-419\" src=\"https:\/\/optimizationup.com\/wp-content\/uploads\/2016\/11\/user-explorer-ga-300x168.jpg\" alt=\"user-explorer-ga\" width=\"655\" height=\"367\" \/><\/p>\n<p>However, these IDs can be only used in the user explorer report and cannot be used as custom dimensions in any of your other reports. And in order to use the client id or user id as dimensions to improve and break down your data, you need to create a custom dimension to retrieve this data and send it back to GA. We will be covering this today, we will learn how to set up custom dimensions via <span style=\"color: #99cc00;\"><a style=\"color: #99cc00;\" href=\"https:\/\/optimizationup.com\/tag\/gtm\/\">Google tag manager<\/a><\/span>. So let&#8217;s start first by the &#8220;Client ID&#8221; custom dimension:<\/p>\n<h5>Client ID Custom Dimension<\/h5>\n<p><strong>\u00a0The first step<\/strong> is to create \u00a0a session-scoped custom dimension through Google analytics interface. Navigate to GA admin tab, select &#8220;Custom Dimensions&#8221; and then name your dimension and save it. Please \u00a0keep in mind the custom dimension <strong>index<\/strong>\u00a0as you are going to need it later:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-416\" src=\"https:\/\/optimizationup.com\/wp-content\/uploads\/2016\/11\/client-id-custom-dimension-300x171.jpg\" alt=\"client-id-custom-dimension\" width=\"547\" height=\"312\" \/><\/p>\n<p>Now you need to <strong>add a custom javascript<\/strong>\u00a0in <span style=\"color: #99cc00;\"><a style=\"color: #99cc00;\" href=\"https:\/\/optimizationup.com\/tag\/gtm\/\">GTM<\/a><\/span> to grab the client ID and returns it to\u00a0the associated property. \u00a0Below is the javascript code, please note that you need to replace the red text with your own property code:-<\/p>\n<pre><code>function() {\n try {\n var trackers = ga.getAll();\n var i, len;\n for (i = 0, len = trackers.length; i &lt; len; i += 1) {\n if (trackers[i].get('trackingId') === '<span style=\"color: #ff0000;\">UA-xxxxxx-1<\/span>') {\n return trackers[i].get('clientId');\n }\n }\n } catch(e) {} \n return 'false';\n}<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Create a window loaded trigger<\/strong> to ensure that our client id tag fires only when the custom javascript returns a valid value<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-418\" src=\"https:\/\/optimizationup.com\/wp-content\/uploads\/2016\/11\/client-id-trigger-300x124.jpg\" alt=\"client-id-trigger\" width=\"537\" height=\"222\" \/><\/p>\n<p><strong>Finally, add a <span style=\"color: #99cc00;\"><a style=\"color: #99cc00;\" href=\"https:\/\/optimizationup.com\/tag\/analytics\/\">Google Analytics<\/a><\/span> event tag<\/strong> and make sure that &#8220;<strong>Non-interaction<\/strong>&#8221; value&#8221; is set to &#8220;<strong>True<\/strong>&#8220;. This prevents the events from being calculated into your sessions. Then, Add your <strong>custom dimension index<\/strong> and then add the<strong> client id variable.<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-414\" src=\"https:\/\/optimizationup.com\/wp-content\/uploads\/2016\/11\/cid-gtm-trigger-300x178.jpg\" alt=\"cid-gtm-trigger\" width=\"598\" height=\"355\" \/><\/p>\n<p>If everything is set up correctly, you should be able to see the client id \u00a0dimension\u00a0in your reports as seen below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-422\" src=\"https:\/\/optimizationup.com\/wp-content\/uploads\/2016\/11\/client-id-report-300x154.jpg\" alt=\"client id report\" width=\"571\" height=\"293\" \/><\/p>\n<h5>User ID Custom Dimension<\/h5>\n<p>If you have the user id feature implemented and you want to expose the id in your GA interface. You will need also to create a custom dimension like we did with the client id dimension above. The only difference is the user id custom dimension would be a\u00a0hit-scoped\u00a0dimension, unlike the client id which is session-scoped. Why? Because you want only to track logged in users and as soon as they log out you stop collecting.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-424\" src=\"https:\/\/optimizationup.com\/wp-content\/uploads\/2016\/11\/user-id-custom-dimension-300x164.jpg\" alt=\"user-id-custom-dimension\" width=\"527\" height=\"288\" \/><\/p>\n<p>The rest of the steps would be the same as we explained in the <strong>client id part<\/strong>. If you encounter any issues implementing the dimension, please\u00a0let me know by leaving a comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google Analytics uses a unique identifier\u00a0to determine if two hits belong to the same user, the unique identifier associated with that particular user must be sent with each hit. GA accomplishes this via Client ID which is a unique, randomly generated string that gets stored in the browser&#8217;s cookies, so subsequent visits to the same&#8230;<\/p>\n<p><a class=\"read-more\" href=\"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":439,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[41,39],"class_list":["post-413","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-measure","tag-analytics","tag-gtm"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Expose Client &amp; User ID in Google Analytics | Optimization Up<\/title>\n<meta name=\"description\" content=\"Google Analytics uses a unique identifier to determine if two hits belong to the same user, the unique identifier associated with that particular user...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Expose Client &amp; User ID in Google Analytics | Optimization Up\" \/>\n<meta property=\"og:description\" content=\"Google Analytics uses a unique identifier to determine if two hits belong to the same user, the unique identifier associated with that particular user...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/\" \/>\n<meta property=\"og:site_name\" content=\"Optimization Up\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/A7med.3lii\" \/>\n<meta property=\"article:published_time\" content=\"2016-11-19T11:51:08+00:00\" \/>\n<meta name=\"author\" content=\"Ahmed Ali\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@A7med_3ly\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ahmed Ali\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/optimizationup.com\\\/expose-client-user-id-google-analytics\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/optimizationup.com\\\/expose-client-user-id-google-analytics\\\/\"},\"author\":{\"name\":\"Ahmed Ali\",\"@id\":\"https:\\\/\\\/optimizationup.com\\\/#\\\/schema\\\/person\\\/75b8aaa058bc4d0630cc7e138840f768\"},\"headline\":\"Expose Client &#038; User ID in Google Analytics\",\"datePublished\":\"2016-11-19T11:51:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/optimizationup.com\\\/expose-client-user-id-google-analytics\\\/\"},\"wordCount\":583,\"commentCount\":14,\"image\":{\"@id\":\"https:\\\/\\\/optimizationup.com\\\/expose-client-user-id-google-analytics\\\/#primaryimage\"},\"thumbnailUrl\":\"\",\"keywords\":[\"Analytics\",\"Google Tag Manager\"],\"articleSection\":[\"Measure\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/optimizationup.com\\\/expose-client-user-id-google-analytics\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/optimizationup.com\\\/expose-client-user-id-google-analytics\\\/\",\"url\":\"https:\\\/\\\/optimizationup.com\\\/expose-client-user-id-google-analytics\\\/\",\"name\":\"Expose Client & User ID in Google Analytics | Optimization Up\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/optimizationup.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/optimizationup.com\\\/expose-client-user-id-google-analytics\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/optimizationup.com\\\/expose-client-user-id-google-analytics\\\/#primaryimage\"},\"thumbnailUrl\":\"\",\"datePublished\":\"2016-11-19T11:51:08+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/optimizationup.com\\\/#\\\/schema\\\/person\\\/75b8aaa058bc4d0630cc7e138840f768\"},\"description\":\"Google Analytics uses a unique identifier to determine if two hits belong to the same user, the unique identifier associated with that particular user...\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/optimizationup.com\\\/expose-client-user-id-google-analytics\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/optimizationup.com\\\/expose-client-user-id-google-analytics\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/optimizationup.com\\\/expose-client-user-id-google-analytics\\\/#primaryimage\",\"url\":\"\",\"contentUrl\":\"\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/optimizationup.com\\\/expose-client-user-id-google-analytics\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/optimizationup.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Expose Client &#038; User ID in Google Analytics\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/optimizationup.com\\\/#website\",\"url\":\"https:\\\/\\\/optimizationup.com\\\/\",\"name\":\"Optimization Up\",\"description\":\"Advanced Optimization &amp; Analytics Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/optimizationup.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/optimizationup.com\\\/#\\\/schema\\\/person\\\/75b8aaa058bc4d0630cc7e138840f768\",\"name\":\"Ahmed Ali\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/68727300a58d1891a3dda2e17e66e7ebd42c80226d3006db77b4814bc14d4d43?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/68727300a58d1891a3dda2e17e66e7ebd42c80226d3006db77b4814bc14d4d43?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/68727300a58d1891a3dda2e17e66e7ebd42c80226d3006db77b4814bc14d4d43?s=96&d=mm&r=g\",\"caption\":\"Ahmed Ali\"},\"description\":\"Entrepreneur focused on building MarTech products that bridge the gap between marketing and technology. Check out my latest products Markifact,\u00a0 Marketing Auditor &amp; GA4 Auditor - discover all my products here.\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/A7med.3lii\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/a7med-ali\\\/\",\"https:\\\/\\\/x.com\\\/A7med_3ly\"],\"url\":\"https:\\\/\\\/optimizationup.com\\\/author\\\/a7med\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Expose Client & User ID in Google Analytics | Optimization Up","description":"Google Analytics uses a unique identifier to determine if two hits belong to the same user, the unique identifier associated with that particular user...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/","og_locale":"en_US","og_type":"article","og_title":"Expose Client & User ID in Google Analytics | Optimization Up","og_description":"Google Analytics uses a unique identifier to determine if two hits belong to the same user, the unique identifier associated with that particular user...","og_url":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/","og_site_name":"Optimization Up","article_author":"https:\/\/www.facebook.com\/A7med.3lii","article_published_time":"2016-11-19T11:51:08+00:00","author":"Ahmed Ali","twitter_card":"summary_large_image","twitter_creator":"@A7med_3ly","twitter_misc":{"Written by":"Ahmed Ali","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/#article","isPartOf":{"@id":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/"},"author":{"name":"Ahmed Ali","@id":"https:\/\/optimizationup.com\/#\/schema\/person\/75b8aaa058bc4d0630cc7e138840f768"},"headline":"Expose Client &#038; User ID in Google Analytics","datePublished":"2016-11-19T11:51:08+00:00","mainEntityOfPage":{"@id":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/"},"wordCount":583,"commentCount":14,"image":{"@id":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/#primaryimage"},"thumbnailUrl":"","keywords":["Analytics","Google Tag Manager"],"articleSection":["Measure"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/","url":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/","name":"Expose Client & User ID in Google Analytics | Optimization Up","isPartOf":{"@id":"https:\/\/optimizationup.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/#primaryimage"},"image":{"@id":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/#primaryimage"},"thumbnailUrl":"","datePublished":"2016-11-19T11:51:08+00:00","author":{"@id":"https:\/\/optimizationup.com\/#\/schema\/person\/75b8aaa058bc4d0630cc7e138840f768"},"description":"Google Analytics uses a unique identifier to determine if two hits belong to the same user, the unique identifier associated with that particular user...","breadcrumb":{"@id":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/#primaryimage","url":"","contentUrl":""},{"@type":"BreadcrumbList","@id":"https:\/\/optimizationup.com\/expose-client-user-id-google-analytics\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/optimizationup.com\/"},{"@type":"ListItem","position":2,"name":"Expose Client &#038; User ID in Google Analytics"}]},{"@type":"WebSite","@id":"https:\/\/optimizationup.com\/#website","url":"https:\/\/optimizationup.com\/","name":"Optimization Up","description":"Advanced Optimization &amp; Analytics Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/optimizationup.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/optimizationup.com\/#\/schema\/person\/75b8aaa058bc4d0630cc7e138840f768","name":"Ahmed Ali","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/68727300a58d1891a3dda2e17e66e7ebd42c80226d3006db77b4814bc14d4d43?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/68727300a58d1891a3dda2e17e66e7ebd42c80226d3006db77b4814bc14d4d43?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/68727300a58d1891a3dda2e17e66e7ebd42c80226d3006db77b4814bc14d4d43?s=96&d=mm&r=g","caption":"Ahmed Ali"},"description":"Entrepreneur focused on building MarTech products that bridge the gap between marketing and technology. Check out my latest products Markifact,\u00a0 Marketing Auditor &amp; GA4 Auditor - discover all my products here.","sameAs":["https:\/\/www.facebook.com\/A7med.3lii","https:\/\/www.linkedin.com\/in\/a7med-ali\/","https:\/\/x.com\/A7med_3ly"],"url":"https:\/\/optimizationup.com\/author\/a7med\/"}]}},"_links":{"self":[{"href":"https:\/\/optimizationup.com\/wp-json\/wp\/v2\/posts\/413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/optimizationup.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/optimizationup.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/optimizationup.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/optimizationup.com\/wp-json\/wp\/v2\/comments?post=413"}],"version-history":[{"count":0,"href":"https:\/\/optimizationup.com\/wp-json\/wp\/v2\/posts\/413\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/optimizationup.com\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/optimizationup.com\/wp-json\/wp\/v2\/media?parent=413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/optimizationup.com\/wp-json\/wp\/v2\/categories?post=413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/optimizationup.com\/wp-json\/wp\/v2\/tags?post=413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}