{"id":144806,"date":"2025-03-20T01:43:24","date_gmt":"2025-03-20T01:43:24","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/enhanced-ecommerce-with-a-custom-javascript-variable\/"},"modified":"2025-03-20T01:43:24","modified_gmt":"2025-03-20T01:43:24","slug":"enhanced-ecommerce-with-a-custom-javascript-variable","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=144806","title":{"rendered":"Enhanced Ecommerce With A Custom JavaScript Variable"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div>\n<p><a href=\"https:\/\/developers.google.com\/analytics\/devguides\/collection\/analyticsjs\/enhanced-ecommerce\">Enhanced Ecommerce<\/a> is a very nice improvement to the pretty lame, <a href=\"https:\/\/developers.google.com\/analytics\/devguides\/collection\/analyticsjs\/ecommerce\">transaction-based Ecommerce<\/a> tracking in Universal Analytics. Instead of staring blindly at what happens on a receipt page, Enhanced Ecommerce expands your entire webstore into one large funnel labelled \u201cShopping Behavior\u201d, and you\u2019re able to zoom in on the Checkout funnel as well. Also, the addition of product-scoped tracking is incredibly useful, and it\u2019s enabled us to think of <em>any<\/em> asset (<a href=\"https:\/\/www.simoahava.com\/analytics\/track-content-enhanced-ecommerce\/\">our content<\/a>, for example) on our site as something we could track through the Enhanced Ecommerce reports.<\/p>\n<div style=\"aspect-ratio: 1908 \/ 882;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/07\/enhanced-ecommerce.jpg\" title=\"Enhanced Ecommerce\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"882\" width=\"1908\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/07\/enhanced-ecommerce.jpg#ZgotmplZ\" alt=\"Enhanced Ecommerce\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>Tracking Enhanced Ecommerce through <a href=\"https:\/\/tagmanager.google.com\">Google Tag Manager<\/a> is <a href=\"https:\/\/developers.google.com\/tag-manager\/enhanced-ecommerce\">pretty straight-forward<\/a>. It boils down to a properly formatted Data Layer, which GTM will then use to send the hits to Google Analytics.<\/p>\n<p>Now, the thing with the Data Layer is that you want to <em>try<\/em> to make it as platform-agnostic as possible. I mean, it doesn\u2019t make sense to encode objects in the Data Layer for one platform\u2019s needs alone, as a complex object syntax will make it quite difficult to reuse the same information for platforms which might have a completely different syntax.<\/p>\n<p>Enhanced Ecommerce requires a <em>very<\/em> specific syntax in the Data Layer object. In addition to this, there are some very ill-designed, Google Analytics -specific, customizations you will need to implement if you want to utilize the Data Layer for Enhanced Ecommerce. An example of these customizations would be adding <a href=\"https:\/\/developers.google.com\/analytics\/devguides\/collection\/analyticsjs\/custom-dims-mets\">product-scoped Custom Dimensions and\/or Metrics<\/a> to the payload.<\/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=\"product-scoped-custom-definitions-the-gtm-way\">Product-scoped Custom Definitions the GTM way<\/h2>\n<p>Here\u2019s an example. Let\u2019s send a product-scoped Custom Dimension with our \u201cAdd To Cart\u201d action. The Custom Dimension will tell whether the product is a promotion or a regular item. The code you\u2019d need in your Data Layer would 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:#0aa\">window<\/span>.dataLayer = <span style=\"color:#0aa\">window<\/span>.dataLayer || [];\n<span style=\"color:#0aa\">window<\/span>.dataLayer.push({\n  <span style=\"color:#a50\">'event'<\/span> : <span style=\"color:#a50\">'addToCart'<\/span>,\n  <span style=\"color:#a50\">'ecommerce'<\/span> : {\n    <span style=\"color:#a50\">'add'<\/span> : {\n      <span style=\"color:#a50\">'products'<\/span> : [{\n        <span style=\"color:#a50\">'id'<\/span> : <span style=\"color:#a50\">'12345'<\/span>,\n        <span style=\"color:#a50\">'name'<\/span> : <span style=\"color:#a50\">'ACME Flame Thrower'<\/span>,\n        <span style=\"color:#a50\">'dimension2'<\/span> : <span style=\"color:#a50\">'Promotion'<\/span>\n      }]\n    }\n  }\n});\n<\/code><\/pre>\n<\/div>\n<p>This hit would prepare the Data Layer for an \u201cAdd To Cart\u201d action, where the value <strong>\u2018Promotion\u2019<\/strong> is sent to GA to Custom Dimension index 2.<\/p>\n<p>Now, this would be fine in a perfect world, where you have an incredibly agile cooperation model with your own developers and with the developers of third-party platforms you have on your site. If the Custom Dimension should change, you can just quickly ask them to push an update to the Data Layer, where <code>dimension2<\/code> is replaced with the new index number.<\/p>\n<p>However, this is rarely the reality. Also, all other parts of the Data Layer object above can be easily reused in other platforms, and the key names (e.g. \u2018id\u2019, \u2018name\u2019) are self-explanatory, but \u2018dimension2\u2019 just won\u2019t ring a bell with platforms that do not think in terms of <em>dimensions<\/em>. So we\u2019ve taken an agnostic Data Layer and turned it very proprietary, respecting the needs of one single platform (Google Analytics) alone.<\/p>\n<h2 id=\"use-a-custom-javascript-variable-instead\">Use a Custom JavaScript Variable instead<\/h2>\n<p>Turns out that you can use a <a href=\"https:\/\/developers.google.com\/tag-manager\/enhanced-ecommerce#macro\">Custom JavaScript Variable to push Enhanced Ecommerce<\/a> payloads to Google Analytics as well:<\/p>\n<div style=\"aspect-ratio: 714 \/ 414;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/07\/enhanced-ecommerce-add-to-cart.jpg\" title=\"Enhanced Ecommerce Custom JavaScript Variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"414\" width=\"714\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/07\/enhanced-ecommerce-add-to-cart.jpg#ZgotmplZ\" alt=\"Enhanced Ecommerce Custom JavaScript Variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>We can thus use a Custom JavaScript Variable to do all the platform-specific customizations, and we can leave our Data Layer as generic as possible.<\/p>\n<p>So, let\u2019s assume we still have the Data Layer in its normal state, but without the \u2018dimension2\u2019 key in it:<\/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:#0aa\">window<\/span>.dataLayer = <span style=\"color:#0aa\">window<\/span>.dataLayer || [];\n<span style=\"color:#0aa\">window<\/span>.dataLayer.push({\n  <span style=\"color:#a50\">'event'<\/span> : <span style=\"color:#a50\">'addToCart'<\/span>,\n  <span style=\"color:#a50\">'ecommerce'<\/span> : {\n    <span style=\"color:#a50\">'add'<\/span> : {\n      <span style=\"color:#a50\">'products'<\/span> : [{\n        <span style=\"color:#a50\">'id'<\/span> : <span style=\"color:#a50\">'12345'<\/span>,\n        <span style=\"color:#a50\">'name'<\/span> : <span style=\"color:#a50\">'ACME Flame Thrower'<\/span>\n      }]\n    }\n  }\n});\n<\/code><\/pre>\n<\/div>\n<p>We want to fire the GA Tag, which sends the Add To Cart action to Google Analytics, when this payload is pushed into Data Layer, but we want to also add the Custom Dimension to the payload without having to modify the <code>dataLayer.push()<\/code> method.<\/p>\n<p>To make this happen, you will first need to create a new <strong>Data Layer Variable<\/strong>, which returns the \u2018ecommerce\u2019 payload:<\/p>\n<div style=\"aspect-ratio: 756 \/ 902;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/07\/dlv-ecommerce.jpg\" title=\"Data Layer Variable ecommerce\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"902\" width=\"756\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/07\/dlv-ecommerce.jpg#ZgotmplZ\" alt=\"Data Layer Variable ecommerce\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>This Variable returns the value of the \u2018ecommerce\u2019 key in the data model. Note, I\u2019m using <strong>Version 1<\/strong> of the Data Layer, because that\u2019s what GTM uses for Enhanced Ecommerce. It protects your Enhanced Ecommerce objects from something called a <em>recursive merge<\/em>, which would result in each \u2018ecommerce\u2019 payload persisting all the previous objects, e.g. \u2018promotions\u2019 and \u2018impressions\u2019 in each hit, resulting in a lot of extra, invalid information being sent to Google Analytics.<\/p>\n<p>Once you have that Variable in place, you will need the actual Custom JavaScript Variable, which I\u2019ve named <strong>{{EEC &#8211; AddToCart With Dimension}}<\/strong>.<\/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\">var<\/span> dIndx = <span style=\"color:#a50\">'2'<\/span>; <span style=\"color:#aaa;font-style:italic\">\/\/ This is the Custom Dimension Index\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>  <span style=\"color:#aaa;font-style:italic\">\/\/ Make a shallow copy of the ecommerce object\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>  <span style=\"color:#00a\">var<\/span> ecom = JSON.parse(JSON.stringify({{DLV - ecommerce}}));\n  <span style=\"color:#00a\">var<\/span> ecomAddProducts = ecom[<span style=\"color:#a50\">'add'<\/span>][<span style=\"color:#a50\">'products'<\/span>];\n  ecomAddProducts[<span style=\"color:#099\">0<\/span>][<span style=\"color:#a50\">'dimension'<\/span> + dIndx] = ecomAddProducts[<span style=\"color:#099\">0<\/span>][<span style=\"color:#a50\">'id'<\/span>] === <span style=\"color:#a50\">'12345'<\/span> ? <span style=\"color:#a50\">'Promotion'<\/span> : <span style=\"color:#a50\">'Regular'<\/span>;\n  <span style=\"color:#00a\">return<\/span> {<span style=\"color:#a50\">'ecommerce'<\/span> : {<span style=\"color:#a50\">'add'<\/span> : {<span style=\"color:#a50\">'products'<\/span> : ecomAddProducts}}};\n}\n<\/code><\/pre>\n<\/div>\n<p>On the first line, you define the Custom Dimension index. Next, you create a little placeholder variable for the \u2018products\u2019 key in the <code>{'ecommerce' : {'add' : {}} }<\/code> object.<\/p>\n<p>Next, you\u2019ll make a copy of the original {{DLV &#8211; ecommerce}} variable by using the <code>JSON.parse(JSON.stringify(obj))<\/code> trick. This is to prevent multiple iterations of the Custom JS variable from inadvertently running whatever modifications you do over and over again on the source variable, resulting in unexpected results.<\/p>\n<p>Then, you basically check if the first (only) product in the \u2018products\u2019 Array has ID \u201812345\u2019. If it does, you add the Custom Dimension key \u2018dimension2\u2019 into the product object with the value \u2018Promotion\u2019. If the ID is something else, the dimension value is set to \u2018Regular\u2019.<\/p>\n<p>You can be very creative here, fetching valid IDs from a Lookup Table, for example. The key thing is to <strong>return a complete \u2018ecommerce\u2019 object<\/strong> in the Custom JavaScript Variable. That\u2019s how GTM works. If you don\u2019t return a syntactically valid \u2018ecommerce\u2019 object, Enhanced Ecommerce will not work.<\/p>\n<p>Just to clarify: a <em>valid<\/em> \u2018ecommerce\u2019 object means that the payload needs to be crafted according to how you would create the Data Layer object. A good place to find more information is in the <a href=\"https:\/\/developers.google.com\/tag-manager\/enhanced-ecommerce\">developer guide<\/a> for the Enhanced Ecommerce Data Layer.<\/p>\n<h2 id=\"things-to-keep-in-mind\">Things to keep in mind<\/h2>\n<p>To make the Custom JavaScript Variable method work with GTM, you will need to remember the following, easy steps:<\/p>\n<ol>\n<li>\n<p>Use a Custom JavaScript Variable which returns a valid <code>{'ecommerce' : {}}<\/code> object<\/p>\n<\/li>\n<li>\n<p>Uncheck <strong>Use data layer<\/strong> in your GA Tag settings<\/p>\n<\/li>\n<li>\n<p>Select the variable you created in (1) in the drop-down menu labelled <strong>Read data from variable<\/strong><\/p>\n<\/li>\n<\/ol>\n<p>That\u2019s all you need to change. Your Tag should still fire on the Custom Event Trigger for Event Name: <strong>addToCart<\/strong>. This time, however, instead of using the Data Layer \u2018ecommerce\u2019 object, it uses the \u2018ecommerce\u2019 object returned by your Custom JavaScript Variable.<\/p>\n<h2 id=\"use-cases\">Use cases<\/h2>\n<p>The best way to use the Custom JavaScript Variable has already been mentioned a few times in this article. Use the Custom JS Variable to turn a generic Data Layer object into a Google Analytics -specific payload. This means that you can ask your developers to implement a very generic Ecommerce payload with the \u201cAdd To Cart\u201d action. This makes it easier for other platforms to tap into the data, as you don\u2019t need to know how Google Analytics works to be able to understand how the object is built.<\/p>\n<p>Another good use case is for product-specific Custom Dimensions and Metrics, which I\u2019ve showed an example of in this article. It doesn\u2019t really make sense to add those to the Data Layer, as dimension and metrics can change, and adding keys that are <em>only<\/em> used by one platform is a bit counter-intuitive.<\/p>\n<p>I\u2019ve found myself using the Custom JavaScript Variable method in almost all the implementations I work with, even if the Data Layer \u2018ecommerce\u2019 object is well-formed to begin with. I like the idea that I can flexibly change the payload on a whim, without having to update the Data Layer.<\/p>\n<p>Naturally, if the changes are fundamental, such as product names changing or IDs receiving a new format, you will want to update the on-page Data Layer instead of encoding these changes in your Custom JavaScript Variable. But the Custom JavaScript Variable is perfect for implementing platform-specific payload syntax in your Ecommerce tracking.<\/p>\n<p>Have you got some other use cases for the Custom JavaScript Variable method? Please, do share!<\/p>\n<\/p><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Enhanced Ecommerce is a very nice improvement to the pretty lame, transaction-based Ecommerce tracking in Universal Analytics. Instead of staring blindly at what happens on a receipt page, Enhanced Ecommerce expands your entire webstore into one large funnel labelled \u201cShopping Behavior\u201d, and you\u2019re able to zoom in on the Checkout funnel as well. Also, the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":144807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[834,11161,14269,29091,15112],"dealstore":[],"offerexpiration":[],"class_list":["post-144806","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-custom","tag-ecommerce","tag-enhanced","tag-javascript","tag-variable"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Enhanced Ecommerce With A Custom JavaScript Variable - 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=144806\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Enhanced Ecommerce With A Custom JavaScript Variable - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"Enhanced Ecommerce is a very nice improvement to the pretty lame, transaction-based Ecommerce tracking in Universal Analytics. Instead of staring blindly at what happens on a receipt page, Enhanced Ecommerce expands your entire webstore into one large funnel labelled \u201cShopping Behavior\u201d, and you\u2019re able to zoom in on the Checkout funnel as well. Also, the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=144806\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-20T01:43:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/enhanced-ecommerce.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1908\" \/>\n\t<meta property=\"og:image:height\" content=\"882\" \/>\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=144806#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=144806\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"Enhanced Ecommerce With A Custom JavaScript Variable\",\"datePublished\":\"2025-03-20T01:43:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=144806\"},\"wordCount\":1298,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=144806#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/enhanced-ecommerce.jpg\",\"keywords\":[\"Custom\",\"ECommerce\",\"enhanced\",\"JavaScript\",\"variable\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=144806#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=144806\",\"url\":\"https:\/\/fivemor.com\/?p=144806\",\"name\":\"Enhanced Ecommerce With A Custom JavaScript Variable - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=144806#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=144806#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/enhanced-ecommerce.jpg\",\"datePublished\":\"2025-03-20T01:43:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=144806#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=144806\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=144806#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/enhanced-ecommerce.jpg\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/enhanced-ecommerce.jpg\",\"width\":1908,\"height\":882},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=144806#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Enhanced Ecommerce With A Custom JavaScript Variable\"}]},{\"@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":"Enhanced Ecommerce With A Custom JavaScript Variable - 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=144806","og_locale":"en_US","og_type":"article","og_title":"Enhanced Ecommerce With A Custom JavaScript Variable - Som2ny Network","og_description":"Enhanced Ecommerce is a very nice improvement to the pretty lame, transaction-based Ecommerce tracking in Universal Analytics. Instead of staring blindly at what happens on a receipt page, Enhanced Ecommerce expands your entire webstore into one large funnel labelled \u201cShopping Behavior\u201d, and you\u2019re able to zoom in on the Checkout funnel as well. Also, the [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=144806","og_site_name":"Som2ny Network","article_published_time":"2025-03-20T01:43:24+00:00","og_image":[{"width":1908,"height":882,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/enhanced-ecommerce.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=144806#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=144806"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"Enhanced Ecommerce With A Custom JavaScript Variable","datePublished":"2025-03-20T01:43:24+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=144806"},"wordCount":1298,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=144806#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/enhanced-ecommerce.jpg","keywords":["Custom","ECommerce","enhanced","JavaScript","variable"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=144806#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=144806","url":"https:\/\/fivemor.com\/?p=144806","name":"Enhanced Ecommerce With A Custom JavaScript Variable - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=144806#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=144806#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/enhanced-ecommerce.jpg","datePublished":"2025-03-20T01:43:24+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=144806#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=144806"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=144806#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/enhanced-ecommerce.jpg","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/enhanced-ecommerce.jpg","width":1908,"height":882},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=144806#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"Enhanced Ecommerce With A Custom JavaScript Variable"}]},{"@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\/144806","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=144806"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/144806\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/144807"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=144806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=144806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=144806"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=144806"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=144806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}