{"id":718,"date":"2015-02-24T20:00:35","date_gmt":"2015-02-24T14:00:35","guid":{"rendered":"http:\/\/promincproductions.com\/blog\/?p=718"},"modified":"2016-02-04T18:50:25","modified_gmt":"2016-02-04T12:50:25","slug":"undocumented-lessons-learned-implementing-google-analytics-universal-enhanced-ecommerce","status":"publish","type":"post","link":"https:\/\/promincproductions.com\/blog\/undocumented-lessons-learned-implementing-google-analytics-universal-enhanced-ecommerce\/","title":{"rendered":"Undocumented Lessons Learned in Implementing Google Analytics Universal with Enhanced Ecommerce"},"content":{"rendered":"<p>While doing a recent update to a site Google Analytics implementation from the traditional codebase to Universal Analytics I came across a few things that I felt were missing from the documentation.<\/p>\n<p>I&#8217;ve chosen to implement Enhanced Ecommerce anaylitics &#8211; extra reporting is always a good thing and so why not do everything I can to ensure that an upgrade is as good as it can be. \u00a0Also, having come from years of working with Adobe Omniture (Adobe Anayltics), Enhanced Ecommerce reporting fills in some of the reporting that I feel is missing in Google Anayltics.<\/p>\n<figure id=\"attachment_722\" aria-describedby=\"caption-attachment-722\" style=\"width: 199px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-722 size-medium\" title=\"Additional sales reports are accessible once Enhanced Ecommerce is enabled and implemented in Universal Analytics.\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Screen-Shot-2015-02-23-at-9.12.35-PM-199x500.png\" alt=\"Use Enhanced Ecommerce to get new sales reports in Google Analytics Universal.\" width=\"199\" height=\"500\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Screen-Shot-2015-02-23-at-9.12.35-PM-199x500.png 199w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Screen-Shot-2015-02-23-at-9.12.35-PM-150x378.png 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Screen-Shot-2015-02-23-at-9.12.35-PM.png 238w\" sizes=\"(max-width: 199px) 100vw, 199px\" \/><figcaption id=\"caption-attachment-722\" class=\"wp-caption-text\">Implementing the Enhanced Ecommerce plugin for Google Analytics Universal opens some great new reports and insights on your sales funnel and product performance.<\/figcaption><\/figure>\n<p>Here is the official\u00a0Enhanced Ecommerce documentation from Google:<br \/> <a title=\"https:\/\/developers.google.com\/analytics\/devguides\/collection\/analyticsjs\/enhanced-ecommerce\" href=\"https:\/\/developers.google.com\/analytics\/devguides\/collection\/analyticsjs\/enhanced-ecommerce\" target=\"_blank\" rel=\"nofollow noopener\" data-lasso-id=\"319\">https:\/\/developers.google.com\/analytics\/devguides\/collection\/analyticsjs\/enhanced-ecommerce<\/a><\/p>\n<p>But now onto the the focus of this article.<\/p>\n<h2>Undocumented Lessons Learned for Implementing Google Universal Analytics with Enhanced Ecommerce<\/h2>\n<h3>Setup a Test Account<\/h3>\n<p>I didn&#8217;t do this. \u00a0Dumb. \u00a0I did all my coding in a development environment, and that allowed me to verify that my tags were sending data. \u00a0All must be good, right? \u00a0Well when I went live with the code, I found some of the issues that led me to write this post, and as a result we missed out on some order data, and it took me a few days to reconfigure some stuff to ensure that all of the data was sending correctly so that the reports work correctly and my custom metrics work how I wanted them to. \u00a0Had I setup another Google Analytics account to send test data to I could have alleviated some of these headaches and mistakes.<\/p>\n<h3>Escape Quotes<\/h3>\n<p>Ensure you escape or remove quotes in your text strings sent to Google Analytics. \u00a0They could break your code if there are erroneous\u00a0quotes in your strings that then break your functions. \u00a0In other words, change things like this:<\/p>\n<pre><code>ga('ec:setAction', 'purchase', {\r\n    'coupon': 'Quotes Don't Matter'\r\n});\r\n<\/code><\/pre>\n<p>To this:<\/p>\n<pre><code>ga('ec:setAction', 'purchase', {\r\n    'coupon': 'Quotes Don\\'t Matter'\r\n});<\/code><\/pre>\n<p>Or this:<\/p>\n<pre><code>ga('ec:setAction', 'purchase', {\r\n    'coupon': 'Quotes Dont Matter'\r\n});<\/code><\/pre>\n<p>See the difference? \u00a0The quote on the word\u00a0<em>Don&#8217;t<\/em> was either escaped or removed. \u00a0Leaving it there would create invalid Javascript and break everything.<\/p>\n<h3>ec:setAction<\/h3>\n<p>ec:setAction is used to track specific Ecommerce actions a user takes such as add a product to the cart, view a product detail page, checkout, etc. \u00a0Look at the official\u00a0documentation for the full list of what actions can all be used.<\/p>\n<p>You set the action with the setAction command &#8211; as an example:<\/p>\n<pre><code>ga('ec:setAction', 'detail');<\/code><\/pre>\n<p>This does NOT get sent to Google Analytics until you send a hit &#8211;\u00a0such as a\u00a0page view, event, etc.<\/p>\n<p>But the hidden lesson here is this: you can <em><strong>NOT<\/strong><\/em> set multiple ec:setAction parameters\u00a0per hit. \u00a0Let me say that again differently: you can only set\u00a0<em><strong>ONE<\/strong><\/em>\u00a0ec:setAction parameter per hit request.<\/p>\n<p>So lets say on the order success \/ confirmation page you wish to use setAction to indicate that a purchase has been completed as well as set the Checkout step, you&#8217;d think you could do the following:<\/p>\n<pre><code>\/* setAction - Purchase *\/\r\nga('ec:setAction', 'purchase', {\r\n 'id': 'PIP12345',\r\n 'affiliation': 'PromInc Productions Web Store',\r\n 'revenue': '99.99',\r\n 'tax': '2.85',\r\n 'shipping': '5.34',\r\n 'coupon': 'TUTORIAL'\r\n});\r\n\r\n\/* setAction - Checkout step *\/\r\nga('ec:setAction','checkout', {'step': 3});\r\n\r\n\/* pageview - Send Hit *\/\r\nga('send', 'pageview');\r\n<\/code><\/pre>\n<p>What happens here though, is that the pageview hit will send and pass the checkout step only with it. \u00a0The purchase setAction will NOT be sent.<\/p>\n<p>The correct way to make this work is to send one of the setAction parameters via the pageview hit. \u00a0Then set the second setAction for the checkout step and it to Google Analytics\u00a0with an event. \u00a0You can set the event to any values you&#8217;d like.<\/p>\n<pre><code>\/* setAction - Purchase *\/\r\nga('ec:setAction', 'purchase', {\r\n 'id': 'PIP12345',\r\n 'affiliation': 'PromInc Productions Web Store',\r\n 'revenue': '99.99',\r\n 'tax': '2.85',\r\n 'shipping': '5.34',\r\n 'coupon': 'TUTORIAL'\r\n});\r\n\r\n\/* pageview - Send Hit *\/\r\nga('send', 'pageview');\r\n\r\n\/* setAction - Checkout step *\/\r\nga('ec:setAction','checkout', {'step': 3});\r\n\r\n\/* event - Purchase *\/\r\nga('send', 'event', 'Cart', 'Purchase', 'PIP12345');\r\n\r\n\r\n<\/code><\/pre>\n<h3>checkout vs checkout_option<\/h3>\n<p>To measure the steps in the checkout process, set ec:setAction to checkout and give it a step number that is then further defined in the Admin section of Google Analytics. \u00a0But there is also a checkout_option that can be set on your ec:setAction. \u00a0Don&#8217;t go thinking like I did that just passing checkout_option would suffice for both. \u00a0checkout_option is just that &#8211; setting and option value to the checkout action. \u00a0But oddly enough, you can send the checkout_option data within the checkout.<\/p>\n<p>Confusing &#8211; I know.<\/p>\n<p>So here&#8217;s what I&#8217;ve come to accept as the best way to handle this scenario:<\/p>\n<pre><code>ga('ec:setAction','checkout', {\r\n 'step': 1,\r\n 'option': 'Visa'\r\n});<\/code><\/pre>\n<p>Here you are sending the checkout action &#8211; which is required to populate the\u00a0<em><strong>Checkout Behavior Analysis<\/strong><\/em> report by defining which step this action correlates to. \u00a0Also however, you are passing a checkout_option value at the same time &#8211; in the case of this example stating the payment method used for this order.<\/p>\n<h3><em>Shopping Behavior Analysis<\/em> Report\u00a0<\/h3>\n<p>The <strong>Shopping Behavior Analysis<\/strong> report is a cool new feature introduced by the Enhanced Ecommerce plugin in Universal Analytics. \u00a0To ensure the data flows into the report, you need to populate all of the ec:setAction parameters through out the customers lifecycle on your site.<\/p>\n<ul>\n<li>ga(&#8216;ec:setAction&#8217;, &#8216;detail&#8217;);\n<ul>\n<li>This populates the second column of the report\u00a0<\/li>\n<li>Set this parameter when a visitor <em><strong>views<\/strong><\/em>\u00a0a\u00a0<strong>Product Detail page<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li>ga(&#8216;ec:setAction&#8217;, &#8216;add&#8217;);\n<ul>\n<li>This populates the third\u00a0column of the report\u00a0<\/li>\n<li>Set this parameter when a visitor <em><strong>adds a product<\/strong><\/em>\u00a0to their cart. \u00a0 I use an AJAX cart so for my implementation this is set on the success event for the AJAX function. \u00a0If you don&#8217;t use an AJAX cart, you can set this parameter when you display a &#8216;added to the cart&#8217; success message.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li>ga(&#8216;ec:setAction&#8217;, &#8216;checkout&#8217;);\n<ul>\n<li>This populates the fourth\u00a0column of the report\u00a0<\/li>\n<li>Set this parameter when a visitor <em><strong>views<\/strong><\/em>\u00a0the <strong>checkout process pages<\/strong>. Typically, this is the first page of your shopping cart \/ checkout process.<\/li>\n<li>You can have multiple of these setAction &#8211; checkout parameters on a site for the various steps of the checkout process. \u00a0To the best of my knowledge, this report is populated by the first of these parameters that you set.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li>ga(&#8216;ec:setAction&#8217;, &#8216;purchase&#8217;);\n<ul>\n<li>This populates the fifth\u00a0column of the report\u00a0<\/li>\n<li>Set this parameter when a visitor <em><strong>views<\/strong><\/em>\u00a0an\u00a0<strong>Order Confirmation page<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<figure id=\"attachment_724\" aria-describedby=\"caption-attachment-724\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Screen-Shot-2015-02-24-at-6.52.24-AM.png\" rel=\"attachment wp-att-724\" data-lasso-id=\"320\" data-rel=\"lightbox-gallery-CVSktwle\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" class=\"size-medium wp-image-724\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Screen-Shot-2015-02-24-at-6.52.24-AM-500x235.png\" alt=\"Use the Enhanced Ecommerce plugin for Universal Analytics to add the Shopping Behavior Analysis report to Google Analytics.\" width=\"500\" height=\"235\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Screen-Shot-2015-02-24-at-6.52.24-AM-500x235.png 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Screen-Shot-2015-02-24-at-6.52.24-AM-768x361.png 768w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Screen-Shot-2015-02-24-at-6.52.24-AM-1024x482.png 1024w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Screen-Shot-2015-02-24-at-6.52.24-AM-150x71.png 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Screen-Shot-2015-02-24-at-6.52.24-AM-600x282.png 600w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Screen-Shot-2015-02-24-at-6.52.24-AM.png 1177w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-724\" class=\"wp-caption-text\">The Shopping Behavior Analysis report in Google Analytics Universal is an added feature with the Enhanced Ecommerce plugin.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h3>Pageviews<\/h3>\n<p>Ok, this one I already knew, but wanted to ensure you all do. \u00a0Be careful with how you use the <strong>send pageview<\/strong>.<\/p>\n<pre><code>ga('send', 'pageview'); <\/code><\/pre>\n<p>Yes, this sends a hit, and as you&#8217;re implementing your code you might be tempted to use this to send a value that is just waiting for a hit to be sent. \u00a0And that is fine. \u00a0But the caution here is that this populates a\u00a0page view for your visitor &#8211; and that should happen only once per pageview. \u00a0So in 99% of implementations, you only want to send\u00a0<strong>one pageview per page request<\/strong>. \u00a0If you need to send another hit to Google Analytics, use the event method instead.<\/p>\n<pre><code>ga('send', 'event', 'Event Category', 'Event Action', 'Event Label');<\/code><\/pre>\n<h3>Product IDs<\/h3>\n<p>On our site, we have two types of product IDs &#8211; a Product ID and an Inventory ID. \u00a0A Product ID can contain multiple Inventory ID&#8217;s. \u00a0So the Product ID is the ID that identifies a tshirt, and the Inventory ID identifies the color of the shirt that the customer buys. \u00a0So the list page displays the Product ID, the customer views a Product Detail Page that offers multiple Inventory IDs (colors) and the customer buys an Inventory ID &#8211; not a Product ID.<\/p>\n<p>All that explanation is for a reason. \u00a0As you send requests to Google Analytics for a lis page product impression, a product add to cart, a product purchase, etc. you need to stay consistent &#8211; else your reports will have a lot of goose eggs, and zeros don&#8217;t help upper management make informed decisions.<\/p>\n<p>So this is just a caution to ensure that you are using the same product ID (when multiple forms are in use) across all of your tracking requests.<\/p>\n<h3>Google Analytics Universal Request Parameters<\/h3>\n<p>Knowing how\u00a0data should be\u00a0sent to Google Analytics can come in handy when debugging. \u00a0Each piece of data gets sent via a query parameter. \u00a0For that reason, I&#8217;ve put together a list of the parameters I know of that get sent to Google Analytics in a reference chart. \u00a0Hopefully it can help you out.<\/p>\n<p><a title=\"Paramater List for Google Analytics Universal with Enhanced Ecommerce\" href=\"https:\/\/promincproductions.com\/blog\/paramater-list-google-analytics-universal-enhanced-ecommerce\/\" data-lasso-id=\"321\">View the Google Analytics Universal with Enhanced Ecommerce Request Query Parameter Reference Chart<\/a><\/p>\n<h3>Request Size<\/h3>\n<p>&#8211;ADDITION September\u00a022nd, 2015&#8211;<\/p>\n<p>The lessons we learn the hard way&#8230;<\/p>\n<p>There is a limit to the size of the request that can be sent to Google Analytics. \u00a0For most requests this probably won&#8217;t be an issue, but an example of where this became an issue for me is on an Ecommerce website on the list (category) page when a large number of products are displayed at once. \u00a0On this page, a\u00a0<strong>ec:addImpression<\/strong>\u00a0command\u00a0is added per product with several parameters set for each product. \u00a0Following the example displayed\u00a0in the <a href=\"https:\/\/developers.google.com\/analytics\/devguides\/collection\/analyticsjs\/enhanced-ecommerce#measuring-activities\" target=\"_blank\" rel=\"nofollow noopener\" data-lasso-id=\"322\">Enhanced Ecommerce\u00a0implementation documentation<\/a>, it is advised to queue up each of the\u00a0<strong>ec:addImpression<\/strong>\u00a0commands and then rely on the\u00a0<strong>ga(&#8216;send&#8217;, &#8216;pageview&#8217;);<\/strong>\u00a0send request to send this data to Google Analytics.<\/p>\n<p>Lets say you display 100 products on this list page &#8211; the request gets very large. \u00a0So large that an error occurs. \u00a0While I&#8217;m not sure where the error lies, it&#8217;s either a browser limitation or a limitation with Google Analytics. \u00a0I know that browsers do have URL length limits (varies per browser &#8211; references: <a href=\"http:\/\/www.boutell.com\/newfaq\/misc\/urllength.html\" target=\"_blank\" rel=\"nofollow noopener\" data-lasso-id=\"323\">#1<\/a>, <a href=\"https:\/\/support.microsoft.com\/en-us\/kb\/208427\" target=\"_blank\" rel=\"nofollow noopener\" data-lasso-id=\"324\">#2<\/a>). \u00a0Also though, while debugging the problem with Fiddler, I did see one of the requests with a long URL string return a 400 response with the following message:<\/p>\n<pre><code>400. That\u2019s an error.\r\n\r\nYour client has issued a malformed or illegal request. That\u2019s all we know.<\/code><\/pre>\n<p>Regardless of where the issue lies, we need to fix this. \u00a0And I&#8217;ll give credit for the solution to <a href=\"https:\/\/code.google.com\/p\/analytics-issues\/issues\/detail?id=448#c9\" target=\"_blank\" data-lasso-id=\"325\" rel=\"noopener\">this issue report<\/a>. \u00a0But the solution comes down to sending an event request after every so many products to prevent hitting this limit. \u00a0How many products? \u00a0That&#8217;s hard to say really since the data that goes with each\u00a0<strong>ec:addImpression<\/strong> request will vary and we don&#8217;t know the real limit we are up against (though most likely 2083 characters). \u00a0The example linked above used 20 products. \u00a0For my recent implementation, I set a rule to send a request every 24 products. \u00a0Why 24? \u00a0That is the default display on our sites list page with the option to show 100 at a time. \u00a0I know that 24 has been working reliably for my site, and so that number seemed to be the right between not too many requests and optimizing the size of the request.<\/p>\n<h3>Update &#8211; Request Size<\/h3>\n<p>&#8211;ADDITION February\u00a04th, 2016&#8211;<\/p>\n<p>There has been some discussion in the comments below that lead me to some more concrete information regarding the request size. \u00a0Thanks to <em><a href=\"https:\/\/promincproductions.com\/blog\/undocumented-lessons-learned-implementing-google-analytics-universal-enhanced-ecommerce\/#comment-44\" data-lasso-id=\"326\">Ky<\/a><\/em> for providing a link to the proper documentation from Google.<\/p>\n<p><a href=\"https:\/\/developers.google.com\/analytics\/devguides\/collection\/protocol\/v1\/reference#using-post\" target=\"_blank\" data-lasso-id=\"327\" rel=\"noopener\">Google Measurement\u00a0Protocol Reference Guide<\/a><\/p>\n<p>There are two ways that a request can be sent to Google &#8211; a GET request or a POST request.<\/p>\n<h4>GET Requests<\/h4>\n<p>A GET request\u00a0is a single URL with query parameters. \u00a0The URL does get URL Encoded (special characters get converted to HTML entities, which are additional characters). \u00a0The maximum size for this URL is 2,000 bytes. \u00a0For those of us that don&#8217;t speak in bits and bytes, <a href=\"https:\/\/web.stanford.edu\/class\/cs101\/bits-bytes.html\" target=\"_blank\" rel=\"nofollow noopener\" data-lasso-id=\"328\">1 byte = 1 character<\/a>.<\/p>\n<h4>POST Requests<\/h4>\n<p>A POST request is a request to a specified URL with an attached payload (additional content). \u00a0The payload is URL encoded (special characters get converted to HTML entities, which are additional characters) like the GET request is, however the payload size limit is much larger. \u00a0A POST request payload can be up to 8,192 bytes (characters). \u00a0For us math people &#8211; that&#8217;s 4 times larger than the GET request.<\/p>\n<h4>Using GET and POST to Your Advantage<\/h4>\n<p>The logical thought pattern knowing the request sizes is to always send requests via POST. \u00a0And I think technically this is possible, however I don&#8217;t know of a simple parameter to set that will make all requests sent via POST.<\/p>\n<p>But, as <em><a href=\"https:\/\/promincproductions.com\/blog\/undocumented-lessons-learned-implementing-google-analytics-universal-enhanced-ecommerce\/#comment-42\" data-lasso-id=\"329\">Ryan Olson<\/a><\/em> pointed out in the comments below,\u00a0some requests are sent via POST by default. \u00a0This information can be useful when designing your strategy on how to best send your requests.\u00a0<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Request Type<\/strong><\/td>\n<td><strong>Request Method<\/strong><\/td>\n<\/tr>\n<tr>\n<td>pageview<\/td>\n<td>GET<\/td>\n<\/tr>\n<tr>\n<td>event<\/td>\n<td>POST<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Avoiding Request Size Limitations<\/h3>\n<p>To illustrate this solution, here is a code example written in very general sense &#8211; you&#8217;ll need to adapt this to fit your coding language.<\/p>\n<pre><code>$counter = 0;\r\nforeach( $products as $product ) {\r\n\r\n $counter += 1;\r\n\r\n &lt;script type=\"text\/javascript\"&gt;\r\n ga('ec:addImpression', {\r\n 'id': '12345',\r\n 'name': 'Product Name',\r\n 'category': 'Parent Category',\r\n 'brand': 'The Best Brand Ever',\r\n 'variant': 'Red',\r\n 'list': 'Search Results',\r\n 'position': 5\r\n });\r\n &lt;\/script&gt;\r\n\r\n if( $counter == 24 ) {\r\n  &lt;script type=\"text\/javascript\"&gt;\r\n  ga('send', 'event', 'Dummy Event', 'List Page', 'Product Impression', 1, {'nonInteraction': 1, 'useBeacon': true } );\r\n  &lt;\/script&gt;\r\n  $counter = 0;\r\n }\r\n\r\n}<\/code><\/pre>\n<h3>Debugging<\/h3>\n<p>As I mentioned above, I used to work quite a bit with Adobe Ominutre. \u00a0Adobe provided a tool for analyzing the tracking requests you sent to them, so debugging and troubleshooting was fairly easy. \u00a0However Google Analytics does not offer their own such tool.<\/p>\n<p>But it is possible to debug your work here. \u00a0In my recent implementation, I noticed data was not\u00a0coming into Google Analytics like I had expected despite me feeling confident about my code. \u00a0Turns out one of my bugs was a stupid mistake of not populating a tag correctly and thus I was sending text into a numeric field and the entire request was being rejected.<\/p>\n<p>That last sentence brings up a point I want to highlight for your debugging. \u00a0<strong>Just because you are sending data to Google Analytics doesn&#8217;t mean that it was accepted by Google Analytics.<\/strong> \u00a0What do I mean by that? \u00a0Well just like I said above &#8211; I was being thrown off by a request not being recorded that I later realized I was sending text in a numeric field. \u00a0So the request left the browser just fine, Google Analytics did receive the request, however because the data was not as they expected it to be, they rejected it on their end. \u00a0So from my browser and debugging standpoint everything was working fine. \u00a0So the point here is to\u00a0<strong>ensure you check your data<\/strong> &#8211; this is both in\u00a0<strong>your requests<\/strong> and in <b>Google Analytics<\/b>. \u00a0Make sure it&#8217;s sending as you expect and make sure it&#8217;s showing in your reports as you expect. \u00a0After-all &#8211; you analytics is only as good as the\u00a0data within it &#8211; if it&#8217;s not accurate or being recorded correctly, your data is useless and will mislead your organization.<\/p>\n<p>To properly debug Google Analytics, lets take a second to ensure that we know how analytics works. \u00a0You set various parameters on the page &#8211; lets say a checkout action, and then send that via a pageview hit. \u00a0What happens is the Google Analytics library will then generate a 1&#215;1 blank image (a pixel) and append to it&#8217;s URL path all of the various query parameters it takes to make up the full request. \u00a0So the values for your checkout action get added to this query parameter string. \u00a0The browser then loads this image, which sends all of these parameters off to Google Analytics\u00a0and the tracking request is complete on the browsers end. \u00a0Google Analytics will now process it, but what happens there is out of the scope of this article and they cover in depth in their <a href=\"https:\/\/analyticsacademy.withgoogle.com\/explorer\" target=\"_blank\" rel=\"nofollow noopener\" data-lasso-id=\"330\">Google Analytics Academy<\/a> program.<\/p>\n<p>So with that background, debugging can be fairly easy &#8211; we just need to be able to view the image request being sent and what parameters are attached to it. \u00a0If we understand what each of those parameters mean, then we can verify that we are passing our data to Google Analytics in the correct format and method and all should be good.<\/p>\n<h3>Google Analytics Debugging Tools<\/h3>\n<p>Debugging tools don&#8217;t like really long requests. \u00a0But the request does seem to make it to Google still. \u00a0An example: for a category page where you are listing lets say 50 products. \u00a0You are instructed to send an impression for each of those products to Google Analytics to power the <b><i>Product List Performance<\/i><\/b><i><\/i> report. \u00a0This results in a request to Google Analytics with a LONG string of query parameters. \u00a0Note the screenshot just below &#8211; the top request is from a category page with long list of impressions. \u00a0The second request is from a click event. \u00a0Despite the debugging tools not displaying the first request correctly, the data does make it into Google Analytics.<\/p>\n<p><a href=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Long-Queries.jpg\" rel=\"attachment wp-att-737\" data-lasso-id=\"331\" data-rel=\"lightbox-gallery-CVSktwle\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" class=\"aligncenter size-medium wp-image-737\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Long-Queries-500x33.jpg\" alt=\"Long Queries\" width=\"500\" height=\"33\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Long-Queries-500x33.jpg 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Long-Queries-150x10.jpg 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Long-Queries-600x40.jpg 600w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Long-Queries.jpg 705w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>One way to debug this better is to limit you code to only show one or two impressions to ensure that it is sending correctly. \u00a0Since this will most likely be in a loop programmatically, you can fairly reliably assume that the other impressions will send fine.<\/p>\n<p>Here are several options for how to see Google Analytics requests.<\/p>\n<h5>Google Analytics Trace Debugging<\/h5>\n<p>There is a debug mode for Google Analytics that outputs additional information to your browsers console window. \u00a0This will allow you to see what parameters are set with each request. \u00a0A LOT of information gets displayed, but it&#8217;s some great insights. \u00a0Here is where you can learn how to enable this mode. \u00a0Of course use this in your development environment only.<\/p>\n<p><a href=\"https:\/\/developers.google.com\/analytics\/devguides\/collection\/analyticsjs\/advanced#debug\" target=\"_blank\" rel=\"nofollow noopener\" data-lasso-id=\"332\">https:\/\/developers.google.com\/analytics\/devguides\/collection\/analyticsjs\/advanced#debug<\/a><\/p>\n<p>NOTE: if you don&#8217;t have anything displayed to your console, there&#8217;s a chance that your sites codebase is blocking the console.log function. \u00a0<a title=\"console.log not working \u2013 Magento\" href=\"https:\/\/promincproductions.com\/blog\/console-log-working-magento\/\" data-lasso-id=\"333\">Here is an article on how to enable it<\/a>.<\/p>\n<h5>Omnibug<\/h5>\n<p><a href=\"http:\/\/omnibug.rosssimpson.com\/\" target=\"_blank\" rel=\"nofollow noopener\" data-lasso-id=\"334\">Omnibug<\/a> has to be my favorite tool for debugging Analytics &#8211; it also works for analyzing\u00a0Facebook, Omniture, and other tracking requests. \u00a0This is a plugin for either Chrome Web Developer Tools or Firebug (Firefox). \u00a0It will show the requests sent to Google Analytics for you and display them in an easy to read display.<\/p>\n<figure id=\"attachment_733\" aria-describedby=\"caption-attachment-733\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-733 size-medium\" title=\"Omnibug displays Google Analytics requests in an easy to read display.\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Capture-500x203.jpg\" alt=\"Use Omnibug to view and debug Google Analytics requests\" width=\"500\" height=\"203\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Capture-500x203.jpg 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Capture-150x61.jpg 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Capture-600x243.jpg 600w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Capture.jpg 753w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><figcaption id=\"caption-attachment-733\" class=\"wp-caption-text\">Omnibug is a great tool to see all Google Analytics requests sent. Twirl down each request to see the full details of what information was sent.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h5>Browser Development Tools Network Panel<\/h5>\n<p>Most browsers now have development tools (or Firebug can be used). \u00a0The network panel shows all HTTP requests. \u00a0In the filter box, filter for\u00a0<em><strong>www.google-analytics.com<\/strong><\/em> to show only Google Analytics requests. \u00a0Those that have\u00a0<em><strong>collect<\/strong><\/em>\u00a0as the URL path are the Google Analytics requests.<\/p>\n<p>Select the request, and then choose the\u00a0<strong>Headers<\/strong> tab to see the request sent. \u00a0The display isn&#8217;t as clean as Omnibug, but certainly has all of the information.<\/p>\n<figure id=\"attachment_729\" aria-describedby=\"caption-attachment-729\" style=\"width: 431px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Network-Panel.jpg\" rel=\"attachment wp-att-729\" data-lasso-id=\"335\" data-rel=\"lightbox-gallery-CVSktwle\" data-rl_title=\"\" data-rl_caption=\"\"><img decoding=\"async\" class=\"wp-image-729 size-full\" title=\"\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Network-Panel.jpg\" alt=\"Use the network panel to view Google Analytics requests.\" width=\"431\" height=\"390\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Network-Panel.jpg 431w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Network-Panel-150x136.jpg 150w\" sizes=\"(max-width: 431px) 100vw, 431px\" \/><\/a><figcaption id=\"caption-attachment-729\" class=\"wp-caption-text\">You can view Google Analytics requests in the browsers development tools Network panel. It&#8217;s not the cleanest display, but all of the information is there.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h5>Fiddler<\/h5>\n<p><a href=\"http:\/\/www.telerik.com\/download\/fiddler\" target=\"_blank\" rel=\"nofollow noopener\" data-lasso-id=\"336\">Fiddler<\/a> is a free Windows based software that sniffs all HTTP\u00a0traffic. \u00a0This can be handy for many reasons, but in this instance we can set a filter for all traffic to\u00a0<em><strong>www.google-analytics.com<\/strong><\/em> and it makes things much easier as there is far less data to weed through. \u00a0Click on a\u00a0<strong>collect<\/strong> request and then click on the\u00a0<strong>Inspectors<\/strong> tab and then the\u00a0<strong>Web Form<\/strong> option for the request.<\/p>\n<figure id=\"attachment_732\" aria-describedby=\"caption-attachment-732\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Fiddler.jpg\" rel=\"attachment wp-att-732\" data-lasso-id=\"337\" data-rel=\"lightbox-gallery-CVSktwle\" data-rl_title=\"\" data-rl_caption=\"\"><img decoding=\"async\" class=\"wp-image-732 size-medium\" title=\"\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Fiddler-500x297.jpg\" alt=\"Fiddler is a free HTTP request sniffer to show you what is being sent to Google Analytics.\" width=\"500\" height=\"297\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Fiddler-500x297.jpg 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Fiddler-150x89.jpg 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Fiddler.jpg 552w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-732\" class=\"wp-caption-text\">Set a filter to view only Google Analytics traffic in Fiddler. Then use the Inspector tab to view the requests.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h5>Live HTTP Headers<\/h5>\n<p><a href=\"http:\/\/livehttpheaders.mozdev.org\/\" target=\"_blank\" rel=\"nofollow noopener\" data-lasso-id=\"338\">Live HTTP Headers<\/a> is a Firefox or Chrome plugin that shows HTTP traffic &#8211; this is similar to Fiddler but not as full featured. \u00a0But it comes in handy from time to time since it&#8217;s platform agonistic being that it&#8217;s a browser plugin.<\/p>\n<figure id=\"attachment_734\" aria-describedby=\"caption-attachment-734\" style=\"width: 289px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Live-HTTP-Headers.jpg\" rel=\"attachment wp-att-734\" data-lasso-id=\"339\" data-rel=\"lightbox-gallery-CVSktwle\" data-rl_title=\"\" data-rl_caption=\"\"><img decoding=\"async\" class=\"wp-image-734 size-medium\" title=\"\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Live-HTTP-Headers-289x500.jpg\" alt=\"Live HTTP Headers is a browser plugin that allows you to see Google Analytics requests.\" width=\"289\" height=\"500\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Live-HTTP-Headers-289x500.jpg 289w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Live-HTTP-Headers-150x259.jpg 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Live-HTTP-Headers.jpg 523w\" sizes=\"(max-width: 289px) 100vw, 289px\" \/><\/a><figcaption id=\"caption-attachment-734\" class=\"wp-caption-text\">Live HTTP Headers is a browser plugin that allows you to HTTP traffic. This allows you to see the requests sent to Google Analytics.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h2>Admin Settings<\/h2>\n<h3>Referral Sources<\/h3>\n<p>&#8211;ADDITION May 4th, 2015&#8211;<\/p>\n<p>I&#8217;m adding this item to the post late, but I&#8217;ve just realized the hard way that I missed yet something else that it would have been VERY NICE to know&#8230; \u00a0After a few months of being on Universal, we started to recognize that some of our channels were down in revenue. \u00a0After doing some digging through the reporting though, I realized that PayPal was DRASTICALLY up as a referral source in regards to revenue, users, transactions, etc. \u00a0Now logically this shouldn&#8217;t even exist as a referral source &#8211; we do not have a link from PayPal to our site. \u00a0Other than when a user completes a purchase through PayPal and is returned to the site&#8230;<\/p>\n<p>Thanks to <a href=\"http:\/\/www.lovesdata.com\/blog\/2010\/tracking-paypal-with-google-analytics\/\" target=\"_blank\" data-lasso-id=\"340\" rel=\"noopener\">this post<\/a>\u00a0I found, I was able to determine how to fix this issue &#8211; well moving forward. \u00a0As you probably know already, Google Analytics is NOT something you can go and correct data in once it&#8217;s been set.<\/p>\n<p>So for the fix, regarding PayPal specifically, there is a way to exclude a referring source in Google Analytics. \u00a0Now this isn&#8217;t something new as the referenced post points out &#8211; this is something that could be done through PayPal for Classic Google Analytics. \u00a0However, Universal Google Analytics doesn&#8217;t respect that fix &#8211; it instead has a different method of implementing the same feature. \u00a0You need to set paypal.com as a\u00a0<strong>Referral Exclusion<\/strong>\u00a0in the Google Analytics Admin. \u00a0See below &#8211; I \u00a0highlight this a bit more.<\/p>\n<p>What this means, is that you are excluding paypal.com from ever showing up in the Referrals report. \u00a0Now that may seem strange, but in the case of your external payment gateways it does make clear sense I&#8217;d say. \u00a0Because what happens is your visitor will enter your site via one channel &#8211; let&#8217;s say they found you through an organic search result. \u00a0They get tracked as such through their visit on your site, decide to purchase and end up on PayPal&#8217;s website. \u00a0They complete their purchase and are sent back to your site&#8217;s success confirmation page. \u00a0At this point is where the problem happens if you did not exclude paypal.com. \u00a0What happens is Google Analytics sees this as a new visit session and your customer is tracked as having a second session on your site. \u00a0Worse yet, because your success page is where you tell GA that the order happened, they get tracked as being referred to your site from paypal.com, not the organic search the initially found your site through. \u00a0And in the case of the site I upgraded, we&#8217;ve been selling for YEARS so this creates a bit of a problem when reporting year over year reporting. \u00a0As of right now, many of our channels appear to be down compared to last year because of this, when the reality (which we don&#8217;t know since the channels are not accurate) is that we probably are doing better than the data shows.<\/p>\n<p>I&#8217;ve highlited PayPal here, but if you use other external payment gateways who operate like PayPal in that they take the customer off site and then back again, this is something you&#8217;ll want to apply to as well.<\/p>\n<h4>Set The Referral Exclusion List in Google Analytics<\/h4>\n<ol>\n<li>Log into your Google Analytics account<\/li>\n<li>Select your property<\/li>\n<li>Click\u00a0<strong>Admin<\/strong> from the top navigation<\/li>\n<li>In the middle column under\u00a0<strong>Property<\/strong>, choose <b>Tracking Info -&gt; Referral Exclusion List<\/b><\/li>\n<li>Click the\u00a0<strong>ADD REFERRAL EXCLUSION<\/strong> button.<\/li>\n<li>Enter the domain you wish to exclude and click\u00a0<strong>Create<\/strong>. \u00a0\n<ul>\n<li>NOTE: I&#8217;d suggest using a domain with now www at the beginning to ensure all subdomains get excluded, unless you know you only want to exclude a specific subdomain<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>Google&#8217;s official documentation on <a href=\"https:\/\/support.google.com\/analytics\/answer\/2795830?hl=en_US\" target=\"_blank\" data-lasso-id=\"341\" rel=\"noopener\">how referral exclusions work in Google Analytics Universa<\/a>l.<\/p>","protected":false},"excerpt":{"rendered":"<p>While doing a recent update to a site Google Analytics implementation from the traditional codebase to Universal Analytics [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":724,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[50,5],"tags":[],"class_list":["post-718","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","category-website-development"],"jetpack_featured_media_url":"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/02\/Screen-Shot-2015-02-24-at-6.52.24-AM.png","jetpack_shortlink":"https:\/\/wp.me\/p4BbcR-bA","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/718","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/comments?post=718"}],"version-history":[{"count":18,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/718\/revisions"}],"predecessor-version":[{"id":1311,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/718\/revisions\/1311"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media\/724"}],"wp:attachment":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media?parent=718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/categories?post=718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/tags?post=718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}