{"id":113584,"date":"2025-02-27T15:46:58","date_gmt":"2025-02-27T15:46:58","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/send-event-and-custom-dimension-if-google-optimize-experiment-is-running\/"},"modified":"2025-02-27T15:46:58","modified_gmt":"2025-02-27T15:46:58","slug":"send-event-and-custom-dimension-if-google-optimize-experiment-is-running","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=113584","title":{"rendered":"Send Event And Custom Dimension If Google Optimize Experiment Is Running"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div>\n<p>I really like <a href=\"https:\/\/optimize.google.com\/optimize\/home\/\">Google Optimize<\/a>. It has a fairly intuitive UI, setting up experiments is easy, and there\u2019s integrations for both <a href=\"https:\/\/tagmanager.google.com\/\">Google Tag Manager<\/a> and <a href=\"https:\/\/analytics.google.com\/\">Google Analytics<\/a> built into the system. It\u2019s still a JavaScript-based, client-side A\/B-testing tool, so problems with flicker and asynchronous loading are ever-present (though this is somewhat mitigated by the <a href=\"https:\/\/developers.google.com\/optimize\/#the_page-hiding_snippet_code\">page-hiding snippet<\/a>).<\/p>\n<p>One issue with the Google Analytics integration is the difficulty of creating segments for sessions where the users were actively participating in the experiment. In fact, there\u2019s no specific signal in Google Analytics that tells you the <strong>NOW<\/strong> the user is \u201cexperiencing\u201d an experiment. You\u2019ll find the <strong>Experiment Name<\/strong> and <strong>Experiment ID<\/strong> dimensions, yes, but they have one drawback:<\/p>\n<p><strong>The <em>Experiment Name<\/em> and <em>Experiment ID<\/em> dimensions are <em>user-scoped<\/em> for the duration of the experiment!<\/strong><\/p>\n<p>So if the user takes part in an experiment, all their hits and sessions from that moment on until the experiment is over will be annotated with the Experiment Name and Experiment ID values.<\/p>\n<div style=\"aspect-ratio: 925 \/ 297;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2017\/11\/custom-dim-exp-id.jpg\" title=\"Custom Dimension with Experiment ID\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"297\" width=\"925\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2017\/11\/custom-dim-exp-id.jpg#ZgotmplZ\" alt=\"Custom Dimension with Experiment ID\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>But I want to know <em>exactly<\/em> and <em>only<\/em> the sessions where my users were seeing the experiment content. I want to use this information to create segments where I can view other conversion goals or funnels than those configured into Optimize. This is increasingly important if you want to use Optimize for some quick personalization proofs-of-concept, since then it\u2019s vital to know how the user reacted during the session when they saw the change in the content.<\/p>\n<p>Anyway, to make this whole thing work with the rarified <strong>analytics.js<\/strong> snippet and <strong>Google Tag Manager<\/strong>, we will use a feature I have seldom written about: <code>customTask<\/code>. OK, I\u2019ve written about it <a href=\"https:\/\/www.simoahava.com\/tags\/customtask\/\">plenty<\/a>.<\/p>\n<p>With <code>customTask<\/code>, we can automatically add a session-scoped Custom Dimension to all hits that took part in an experiment, and in some edge cases we\u2019ll also send an event to GA to make sure the data is carried over.<\/p>\n<p>                <span class=\"simmer\"><br \/>\n  <span class=\"close\">X<\/span><\/p>\n<p>\n    <span class=\"fa fa-md fa-bell\"\/><br \/>\n    <strong>The Simmer Newsletter<\/strong>\n  <\/p>\n<p>\n    Subscribe to the <a href=\"https:\/\/www.simoahava.com\/newsletter\/\">Simmer newsletter<\/a> to get the latest news and content from Simo Ahava into your email inbox!\n  <\/p>\n<p>  <\/span><\/p>\n<h2 id=\"how-it-works\">How it works<\/h2>\n<p>When you land on a page where an Optimize experiment is running (i.e. the page is (one of) the target(s) of the experiment), your Google Analytics hits will contain the <strong>&amp;exp<\/strong> parameter with a value consisting of all the experiment IDs and variant IDs the user is participating in:<\/p>\n<div style=\"aspect-ratio: 1001 \/ 427;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2017\/11\/exp-key.jpg\" title=\"exp key in payload\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"427\" width=\"1001\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2017\/11\/exp-key.jpg#ZgotmplZ\" alt=\"exp key in payload\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>This key is what GA then uses to attribute the user to these particular experiments. So once that hit reaches GA, my Client ID will be associated with those two experiment IDs until the experiment is over.<\/p>\n<p>Now, what I actually want to happen is for a Custom Dimension to be added to that Page View hit if it has the <strong>&amp;exp<\/strong> key. For this, I need to use <code>customTask<\/code> so that it can sniff the requests to Google Analytics, and in case they contain this key, dynamically add the Custom Dimension parameter with the experiment string. That way I\u2019ll have the experiment data sent to Google Analytics nicely in the Custom Dimension of my choice!<\/p>\n<p>If you\u2019re using <strong>Google Tag Manager<\/strong> to deploy Google Optimize, the same code will apply, but instead of leveraging a Page View hit, the Optimize tag will use a special <code>hitType === 'data'<\/code> hit, which takes your experiment data to GA.<\/p>\n<div style=\"aspect-ratio: 947 \/ 312;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2017\/11\/data-hittype-gtm.jpg\" title=\"hittype data parameter gtm\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"312\" width=\"947\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2017\/11\/data-hittype-gtm.jpg#ZgotmplZ\" alt=\"hittype data parameter gtm\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>Unfortunately for us, this <code>data<\/code> hit type is not exposed in Google Analytics, so we can\u2019t use that to segment our visitors, nor does piggy-backing it with a Custom Dimension do anything. So, we need to configure Google Tag Manager to actually send an extra <strong>event<\/strong> when a <code>data<\/code> hit is encountered that also has the <strong>&amp;exp<\/strong> parameter with it.<\/p>\n<h2 id=\"implement-via-analyticsjs\">Implement via analytics.js<\/h2>\n<p>If you\u2019re using the <strong>analytics.js<\/strong> snippet, here\u2019s what you need to do:<\/p>\n<div class=\"highlight\">\n<pre style=\"background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-html\" data-lang=\"html\">script&gt;\n  <span style=\"color:#aaa;font-style:italic\">\/\/ Analytics.js snippet\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>  (<span style=\"color:#00a\">function<\/span>(i,s,o,g,r,a,m){i[<span style=\"color:#a50\">'GoogleAnalyticsObject'<\/span>]=r;i[r]=i[r]||<span style=\"color:#00a\">function<\/span>(){\n(i[r].q=i[r].q||[]).push(arguments)},i[r].l=<span style=\"color:#099\">1<\/span>*<span style=\"color:#00a\">new<\/span> <span style=\"color:#0aa\">Date<\/span>();a=s.createElement(o),\nm=s.getElementsByTagName(o)[<span style=\"color:#099\">0<\/span>];a.async=<span style=\"color:#099\">1<\/span>;a.src=g;m.parentNode.insertBefore(a,m)\n})(<span style=\"color:#0aa\">window<\/span>,<span style=\"color:#0aa\">document<\/span>,<span style=\"color:#a50\">'script'<\/span>,<span style=\"color:#a50\">'https:\/\/www.google-analytics.com\/analytics.js'<\/span>,<span style=\"color:#a50\">'ga'<\/span>);\n\n  ga(<span style=\"color:#a50\">'create'<\/span>, <span style=\"color:#a50\">'UA-XXXXXX-Y'<\/span>,<span style=\"color:#a50\">'auto'<\/span>)\n\n  <span style=\"color:#aaa;font-style:italic\">\/\/ NEW: Add customTask field to tracker\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>  ga(<span style=\"color:#a50\">'set'<\/span>, <span style=\"color:#a50\">'customTask'<\/span>,  <span style=\"color:#00a\">function<\/span>(model) {\n\n    <span style=\"color:#aaa;font-style:italic\">\/\/ Change this to the Custom Dimension index to which you want to send the experiment data!\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>    <span style=\"color:#00a\">var<\/span> customDimensionIndex = <span style=\"color:#a50\">'6'<\/span>;\n    \n    <span style=\"color:#aaa;font-style:italic\">\/\/ Make sure the new hit is only generated once (thanks Vibhor Jain!)\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>    <span style=\"color:#00a\">var<\/span> hasNewHitBeenGenerated = <span style=\"color:#00a\">false<\/span>;\n    \n    <span style=\"color:#00a\">var<\/span> globalSendTaskName = <span style=\"color:#a50\">'_'<\/span> + model.get(<span style=\"color:#a50\">'trackingId'<\/span>) + <span style=\"color:#a50\">'_sendHitTask'<\/span>;\n    \n    <span style=\"color:#00a\">var<\/span> originalSendTask = <span style=\"color:#0aa\">window<\/span>[globalSendTaskName] = <span style=\"color:#0aa\">window<\/span>[globalSendTaskName] || model.get(<span style=\"color:#a50\">'sendHitTask'<\/span>);\n    \n    model.set(<span style=\"color:#a50\">'sendHitTask'<\/span>, <span style=\"color:#00a\">function<\/span>(sendModel) {\n      <span style=\"color:#00a\">var<\/span> ga = <span style=\"color:#0aa\">window<\/span>[<span style=\"color:#0aa\">window<\/span>[<span style=\"color:#a50\">'GoogleAnalyticsObject'<\/span>]];\n      <span style=\"color:#00a\">var<\/span> hitPayload = sendModel.get(<span style=\"color:#a50\">'hitPayload'<\/span>);\n      <span style=\"color:#00a\">if<\/span> (sendModel.get(<span style=\"color:#a50\">'exp'<\/span>)) {\n        <span style=\"color:#00a\">if<\/span> (sendModel.get(<span style=\"color:#a50\">'hitType'<\/span>) === <span style=\"color:#a50\">'data'<\/span> &amp;&amp; !hasNewHitBeenGenerated) {\n          <span style=\"color:#00a\">var<\/span> tracker = sendModel.get(<span style=\"color:#a50\">'name'<\/span>);\n          originalSendTask(sendModel);\n          ga(tracker + <span style=\"color:#a50\">'.send'<\/span>, <span style=\"color:#a50\">'event'<\/span>, <span style=\"color:#a50\">'Optimize'<\/span>, sendModel.get(<span style=\"color:#a50\">'exp'<\/span>), {nonInteraction: <span style=\"color:#00a\">true<\/span>});\n          hasNewHitBeenGenerated = <span style=\"color:#00a\">true<\/span>;\n          <span style=\"color:#00a\">return<\/span>;\n        }\n        <span style=\"color:#00a\">if<\/span> (hitPayload.indexOf(<span style=\"color:#a50\">'&amp;cd'<\/span> + customDimensionIndex + <span style=\"color:#a50\">'='<\/span>) === -<span style=\"color:#099\">1<\/span>) {\n          sendModel.set(<span style=\"color:#a50\">'hitPayload'<\/span>, hitPayload + <span style=\"color:#a50\">'&amp;cd'<\/span> + customDimensionIndex + <span style=\"color:#a50\">'='<\/span> + sendModel.get(<span style=\"color:#a50\">'exp'<\/span>), <span style=\"color:#00a\">true<\/span>);\n        }\n      }\n      originalSendTask(sendModel);\n    });\n  });\n  <span style=\"color:#aaa;font-style:italic\">\/\/ NEW BLOCK ENDS\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>\n  ga(<span style=\"color:#a50\">'require'<\/span>, <span style=\"color:#a50\">'GTM-XXXXXX'<\/span>);\n  ga(<span style=\"color:#a50\">'send'<\/span>, <span style=\"color:#a50\">'pageview'<\/span>);\n<span style=\"color:#1e90ff;font-weight:bold\">script<\/span>&gt;<\/code><\/pre>\n<\/div>\n<p>The change to the original Optimize-modified analytics.js snippet is the entire block starting with <code>\/\/ NEW:...<\/code> and ending with <code>\/\/ NEW BLOCK ENDS<\/code>.<\/p>\n<p>This code listens to all GA hits sent with the default tracker, and if they have the <strong>&amp;exp<\/strong> parameter, then the Custom Dimension is dynamically added to the hits, along with the experiment ID string the user is associated with. Note that you must change the value of <code>var customDimensionIndex<\/code> to reflect the Custom Dimension index you\u2019ve created in Google Analytics. I prefer to use a <strong>Session-scoped Custom Dimension<\/strong>, but you could use hit-scoped, too, for increased granularity.<\/p>\n<div style=\"aspect-ratio: 1089 \/ 201;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2017\/11\/custom-dimension.jpg\" title=\"Custom Dimension in GA\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"201\" width=\"1089\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2017\/11\/custom-dimension.jpg#ZgotmplZ\" alt=\"Custom Dimension in GA\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>That\u2019s all you need to do with <strong>analytics.js<\/strong>. On pages not included in the experiment, no Custom Dimension or any extra hit is sent. Business will be as usual.<\/p>\n<h2 id=\"implement-via-google-tag-manager\">Implement via Google Tag Manager<\/h2>\n<p>In Google Tag Manager, you need to create a new <strong>Custom JavaScript variable<\/strong>, and give it a name like <strong>{{JS &#8211; customTask &#8211; Optimize experiment}}<\/strong>. The variable should look like this:<\/p>\n<div class=\"highlight\">\n<pre style=\"background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-javascript\" data-lang=\"javascript\"><span style=\"color:#00a\">function<\/span>() {\n  <span style=\"color:#00a\">return<\/span> <span style=\"color:#00a\">function<\/span>(model) {\n    \n    <span style=\"color:#aaa;font-style:italic\">\/\/ Change this to the Custom Dimension index to which you want to send the experiment data!\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>    <span style=\"color:#00a\">var<\/span> customDimensionIndex = <span style=\"color:#a50\">'6'<\/span>;\n\n    <span style=\"color:#aaa;font-style:italic\">\/\/ Make sure the new hit is only generated once (thanks Vibhor Jain!)\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>    <span style=\"color:#00a\">var<\/span> hasNewHitBeenGenerated = <span style=\"color:#00a\">false<\/span>;\n    \n    <span style=\"color:#00a\">var<\/span> globalSendTaskName = <span style=\"color:#a50\">'_'<\/span> + model.get(<span style=\"color:#a50\">'trackingId'<\/span>) + <span style=\"color:#a50\">'_sendHitTask'<\/span>;\n    \n    <span style=\"color:#00a\">var<\/span> originalSendTask = <span style=\"color:#0aa\">window<\/span>[globalSendTaskName] = <span style=\"color:#0aa\">window<\/span>[globalSendTaskName] || model.get(<span style=\"color:#a50\">'sendHitTask'<\/span>);\n\n    model.set(<span style=\"color:#a50\">'sendHitTask'<\/span>, <span style=\"color:#00a\">function<\/span>(sendModel) {\n      <span style=\"color:#00a\">var<\/span> ga = <span style=\"color:#0aa\">window<\/span>[<span style=\"color:#0aa\">window<\/span>[<span style=\"color:#a50\">'GoogleAnalyticsObject'<\/span>]];\n      <span style=\"color:#00a\">var<\/span> hitPayload = sendModel.get(<span style=\"color:#a50\">'hitPayload'<\/span>);\n      <span style=\"color:#00a\">if<\/span> (sendModel.get(<span style=\"color:#a50\">'exp'<\/span>)) {\n        <span style=\"color:#00a\">if<\/span> (sendModel.get(<span style=\"color:#a50\">'hitType'<\/span>) === <span style=\"color:#a50\">'data'<\/span> &amp;&amp; !hasNewHitBeenGenerated) {\n          <span style=\"color:#00a\">var<\/span> tracker = sendModel.get(<span style=\"color:#a50\">'name'<\/span>);\n          originalSendTask(sendModel);\n          ga(tracker + <span style=\"color:#a50\">'.send'<\/span>, <span style=\"color:#a50\">'event'<\/span>, <span style=\"color:#a50\">'Optimize'<\/span>, sendModel.get(<span style=\"color:#a50\">'exp'<\/span>), {nonInteraction: <span style=\"color:#00a\">true<\/span>});\n          hasNewHitBeenGenerated = <span style=\"color:#00a\">true<\/span>;\n          <span style=\"color:#00a\">return<\/span>;\n        }\n        <span style=\"color:#00a\">if<\/span> (hitPayload.indexOf(<span style=\"color:#a50\">'&amp;cd'<\/span> + customDimensionIndex + <span style=\"color:#a50\">'='<\/span>) === -<span style=\"color:#099\">1<\/span>) {\n          sendModel.set(<span style=\"color:#a50\">'hitPayload'<\/span>, hitPayload + <span style=\"color:#a50\">'&amp;cd'<\/span> + customDimensionIndex + <span style=\"color:#a50\">'='<\/span> + sendModel.get(<span style=\"color:#a50\">'exp'<\/span>), <span style=\"color:#00a\">true<\/span>);\n        }\n      }\n      originalSendTask(sendModel);\n    });\n  };\n}\n<\/code><\/pre>\n<\/div>\n<p>It\u2019s pretty much exactly the same code you would use in the <strong>analytics.js<\/strong>.<\/p>\n<p>Then, go to your <strong>Google Optimize<\/strong> tag, and scroll down to <strong>Fields to set<\/strong>. Add a new field with:<\/p>\n<p>Field name: <strong>customTask<\/strong><br \/>Value: <strong>{{JS &#8211; customTask &#8211; Optimize experiment}}<\/strong><\/p>\n<p>So that it looks like this:<\/p>\n<div style=\"aspect-ratio: 883 \/ 527;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2017\/11\/optimize-tag-gtm.jpg\" title=\"Optimize tag in Google Tag Manager\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"527\" width=\"883\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2017\/11\/optimize-tag-gtm.jpg#ZgotmplZ\" alt=\"Optimize tag in Google Tag Manager\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>And that should be it. Now when you browser the experiment pages, you should see a hit with type <code>'data'<\/code> being sent, and immediately after that an event hit which looks like this:<\/p>\n<div style=\"aspect-ratio: 991 \/ 426;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2017\/11\/extra-event-hit.jpg\" title=\"Extra event hit\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"426\" width=\"991\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2017\/11\/extra-event-hit.jpg#ZgotmplZ\" alt=\"Extra event hit\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<h2 id=\"summary\">Summary<\/h2>\n<p>I really wish that the Optimize \/ Google Analytics integration would give us a hit or dimension we could use to segment sessions that actively participated in an experiment. Right now you either need to replicate the test conditions in a segment (and if you sample only a part of your visitors even this won\u2019t cut it), or use a solution like the one described in this article.<\/p>\n<p>Even if this were superfluous and unnecessary, I\u2019m giddy with excitement to show yet another cool use case for <code>customTask<\/code>. I\u2019m fairly certain that if we hadn\u2019t already given our baby boy a gorgeous name, the world would have come to know him as <strong>customTask Ahava<\/strong>. For now, it will have to do as his nickname. That\u2019s how much I love <code>customTask<\/code>!<\/p>\n<\/p><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>I really like Google Optimize. It has a fairly intuitive UI, setting up experiments is easy, and there\u2019s integrations for both Google Tag Manager and Google Analytics built into the system. It\u2019s still a JavaScript-based, client-side A\/B-testing tool, so problems with flicker and asynchronous loading are ever-present (though this is somewhat mitigated by the page-hiding [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":113585,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[834,34452,9252,8329,1531,11464,325,11285],"dealstore":[],"offerexpiration":[],"class_list":["post-113584","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-custom","tag-dimension","tag-event","tag-experiment","tag-google","tag-optimize","tag-running","tag-send"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Send Event And Custom Dimension If Google Optimize Experiment Is Running - Som2ny Network<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fivemor.com\/?p=113584\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Send Event And Custom Dimension If Google Optimize Experiment Is Running - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"I really like Google Optimize. It has a fairly intuitive UI, setting up experiments is easy, and there\u2019s integrations for both Google Tag Manager and Google Analytics built into the system. It\u2019s still a JavaScript-based, client-side A\/B-testing tool, so problems with flicker and asynchronous loading are ever-present (though this is somewhat mitigated by the page-hiding [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=113584\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-27T15:46:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/custom-dim-exp-id.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"925\" \/>\n\t<meta property=\"og:image:height\" content=\"297\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=113584#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=113584\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"Send Event And Custom Dimension If Google Optimize Experiment Is Running\",\"datePublished\":\"2025-02-27T15:46:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=113584\"},\"wordCount\":1024,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=113584#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/custom-dim-exp-id.jpg\",\"keywords\":[\"Custom\",\"Dimension\",\"event\",\"EXPERIMENT\",\"Google\",\"Optimize\",\"Running\",\"send\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=113584#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=113584\",\"url\":\"https:\/\/fivemor.com\/?p=113584\",\"name\":\"Send Event And Custom Dimension If Google Optimize Experiment Is Running - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=113584#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=113584#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/custom-dim-exp-id.jpg\",\"datePublished\":\"2025-02-27T15:46:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=113584#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=113584\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=113584#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/custom-dim-exp-id.jpg\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/custom-dim-exp-id.jpg\",\"width\":925,\"height\":297},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=113584#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Send Event And Custom Dimension If Google Optimize Experiment Is Running\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fivemor.com\/#website\",\"url\":\"https:\/\/fivemor.com\/\",\"name\":\"Som2ny Network\",\"description\":\"Daily Deals\",\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fivemor.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/fivemor.com\/#organization\",\"name\":\"Som2ny Network\",\"url\":\"https:\/\/fivemor.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"width\":300,\"height\":86,\"caption\":\"Som2ny Network\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/fivemor.com\"],\"url\":\"https:\/\/fivemor.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Send Event And Custom Dimension If Google Optimize Experiment Is Running - Som2ny Network","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:\/\/fivemor.com\/?p=113584","og_locale":"en_US","og_type":"article","og_title":"Send Event And Custom Dimension If Google Optimize Experiment Is Running - Som2ny Network","og_description":"I really like Google Optimize. It has a fairly intuitive UI, setting up experiments is easy, and there\u2019s integrations for both Google Tag Manager and Google Analytics built into the system. It\u2019s still a JavaScript-based, client-side A\/B-testing tool, so problems with flicker and asynchronous loading are ever-present (though this is somewhat mitigated by the page-hiding [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=113584","og_site_name":"Som2ny Network","article_published_time":"2025-02-27T15:46:58+00:00","og_image":[{"width":925,"height":297,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/custom-dim-exp-id.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=113584#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=113584"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"Send Event And Custom Dimension If Google Optimize Experiment Is Running","datePublished":"2025-02-27T15:46:58+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=113584"},"wordCount":1024,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=113584#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/custom-dim-exp-id.jpg","keywords":["Custom","Dimension","event","EXPERIMENT","Google","Optimize","Running","send"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=113584#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=113584","url":"https:\/\/fivemor.com\/?p=113584","name":"Send Event And Custom Dimension If Google Optimize Experiment Is Running - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=113584#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=113584#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/custom-dim-exp-id.jpg","datePublished":"2025-02-27T15:46:58+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=113584#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=113584"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=113584#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/custom-dim-exp-id.jpg","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/custom-dim-exp-id.jpg","width":925,"height":297},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=113584#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"Send Event And Custom Dimension If Google Optimize Experiment Is Running"}]},{"@type":"WebSite","@id":"https:\/\/fivemor.com\/#website","url":"https:\/\/fivemor.com\/","name":"Som2ny Network","description":"Daily Deals","publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fivemor.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fivemor.com\/#organization","name":"Som2ny Network","url":"https:\/\/fivemor.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","width":300,"height":86,"caption":"Som2ny Network"},"image":{"@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","caption":"admin"},"sameAs":["https:\/\/fivemor.com"],"url":"https:\/\/fivemor.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/113584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=113584"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/113584\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/113585"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=113584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=113584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=113584"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=113584"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=113584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}