<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>Google Tag Manager Archives - rweber.net</title>
	<atom:link href="https://www.rweber.net/tag/google-tag-manager/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.rweber.net/tag/google-tag-manager/</link>
	<description>trying to be a mile wide AND a mile deep</description>
	<lastBuildDate>Sun, 17 Dec 2017 13:33:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">37896774</site>	<item>
		<title>Sending Enhanced Ecommerce data on pageview without a hard-coded datalayer</title>
		<link>https://www.rweber.net/analytics/sending-enhanced-ecommerce-data-pageview-without-hard-coded-datalayer/</link>
					<comments>https://www.rweber.net/analytics/sending-enhanced-ecommerce-data-pageview-without-hard-coded-datalayer/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 18 Sep 2017 12:00:35 +0000</pubDate>
				<category><![CDATA[Analytics]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Google Tag Manager]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=40131</guid>

					<description><![CDATA[<div><img width="300" height="190" src="https://www.rweber.net/wp-content/uploads/2017/09/success-882592_640-300x190.jpg" class="attachment-medium size-medium wp-post-image" alt="Plan B image by sciencefreak on Pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" fetchpriority="high" srcset="https://www.rweber.net/wp-content/uploads/2017/09/success-882592_640-300x190.jpg 300w, https://www.rweber.net/wp-content/uploads/2017/09/success-882592_640-150x95.jpg 150w, https://www.rweber.net/wp-content/uploads/2017/09/success-882592_640.jpg 640w" sizes="(max-width: 300px) 100vw, 300px" /></div>
<p>A long title for a short post about reading from a custom GTM variable as though it were the datalayer.</p>
<p>The post <a href="https://www.rweber.net/analytics/sending-enhanced-ecommerce-data-pageview-without-hard-coded-datalayer/">Sending Enhanced Ecommerce data on pageview without a hard-coded datalayer</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="190" src="https://www.rweber.net/wp-content/uploads/2017/09/success-882592_640-300x190.jpg" class="attachment-medium size-medium wp-post-image" alt="Plan B image by sciencefreak on Pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" srcset="https://www.rweber.net/wp-content/uploads/2017/09/success-882592_640-300x190.jpg 300w, https://www.rweber.net/wp-content/uploads/2017/09/success-882592_640-150x95.jpg 150w, https://www.rweber.net/wp-content/uploads/2017/09/success-882592_640.jpg 640w" sizes="(max-width: 300px) 100vw, 300px" /></div><p>We&#8217;ve discussed why you might want to <a href="https://www.rweber.net/web-development/javascript/ga-enhanced-ecommerce-using-gtm/">delay sending product impression data to Google Analytics</a> via event triggering, so that your product impressions are actually reflective of products appearing onscreen. However, that means you are adding event hits to your GA total hits, so ideally you will only send impressions as events when you truly need to. If you&#8217;re sending a product detail impression or a promotion impression for a banner at the top of the page, it makes more sense to send the EEc data as payload on the pageview tag (yes, tag &#8211; I&#8217;m assuming you&#8217;re using Google Tag Manager).</p>
<p>The preferred way to give the details to GTM is in the datalayer, but that requires all the EEc information be present in the page in the appropriate syntax upon page load, and sometimes that&#8217;s just not practical. However, you can provide the data in a variable instead &#8211; see <a href="https://support.google.com/tagmanager/answer/6107169">Google Support&#8217;s basic Ecommerce Tracking article</a> for as much as Google has to tell you on the matter; the full developer documentation doesn&#8217;t say any more.</p>
<p>Basically, you enable Enhanced Ecommerce features but do not check &#8220;Use Data Layer.&#8221; Instead you can create a GTM custom JavaScript variable that the tag will read from as though it is the datalayer (so a small caveat: this is incompatible with using the datalayer in the same tag, but other tags firing on the page can use the datalayer even if the pageview tag is reading a variable). That variable has to return the object you would otherwise push into the datalayer.</p>
<p>The key to this working, of course, is that even though the tag will fire at page load, you can scrape the page&#8217;s contents to construct your datalayer object just the same as if you were pushing to the datalayer to trigger an event (as we did when <a href="https://www.rweber.net/web-development/adding-url-parameters-google-tag-manager-dont-literal/">adding campaign tracking data</a> recently).</p>
<hr>
<p><small> Plan B image by <a href="https://pixabay.com/en/success-plan-b-strategy-economy-882592/">sciencefreak on Pixabay</a>.</small></p>
<p>The post <a href="https://www.rweber.net/analytics/sending-enhanced-ecommerce-data-pageview-without-hard-coded-datalayer/">Sending Enhanced Ecommerce data on pageview without a hard-coded datalayer</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/analytics/sending-enhanced-ecommerce-data-pageview-without-hard-coded-datalayer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">40131</post-id>	</item>
		<item>
		<title>Adding URL parameters with Google Tag Manager: Don&#8217;t be too literal</title>
		<link>https://www.rweber.net/analytics/adding-url-parameters-google-tag-manager-dont-literal/</link>
					<comments>https://www.rweber.net/analytics/adding-url-parameters-google-tag-manager-dont-literal/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 03 Jul 2017 12:00:13 +0000</pubDate>
				<category><![CDATA[Analytics]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Google Tag Manager]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=40095</guid>

					<description><![CDATA[<div><img width="200" height="300" src="https://www.rweber.net/wp-content/uploads/2017/06/thinking-monkey-200x300.jpg" class="attachment-medium size-medium wp-post-image" alt="thinking monkeyimage from publicdomainpictures.net" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" srcset="https://www.rweber.net/wp-content/uploads/2017/06/thinking-monkey-200x300.jpg 200w, https://www.rweber.net/wp-content/uploads/2017/06/thinking-monkey-100x150.jpg 100w, https://www.rweber.net/wp-content/uploads/2017/06/thinking-monkey.jpg 410w" sizes="(max-width: 200px) 100vw, 200px" /></div>
<p>A quick reminder about adding information to pageviews.</p>
<p>The post <a href="https://www.rweber.net/analytics/adding-url-parameters-google-tag-manager-dont-literal/">Adding URL parameters with Google Tag Manager: Don&#8217;t be too literal</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="200" height="300" src="https://www.rweber.net/wp-content/uploads/2017/06/thinking-monkey-200x300.jpg" class="attachment-medium size-medium wp-post-image" alt="thinking monkeyimage from publicdomainpictures.net" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2017/06/thinking-monkey-200x300.jpg 200w, https://www.rweber.net/wp-content/uploads/2017/06/thinking-monkey-100x150.jpg 100w, https://www.rweber.net/wp-content/uploads/2017/06/thinking-monkey.jpg 410w" sizes="auto, (max-width: 200px) 100vw, 200px" /></div><p>Just a quick tip this morning.</p>
<p>Suppose you have incoming traffic that you&#8217;d like to track as though the URLs were tagged with UTM parameters. And suppose you use Google Tag Manager to send data to Google Analytics. You might be tempted to tack a query string onto the URL in the &#8220;page&#8221; field, especially if you&#8217;re already doing something to the &#8220;page&#8221; field (e.g. cleaning out potential PII).</p>
<p>However, you might also find that doesn&#8217;t work worth a darn, despite seeing numerous tutorials online that indicate it works great &#8211; at least for parameters like search term. In that case, remember that setting the &#8220;page&#8221; field is but one example of directly setting any field you should so desire &#8211; including campaignName (utm_campaign), campaignSource (utm_source), campaignMedium (utm_medium), and any other campaign-related fields that are relevant.</p>
<p><strong>Edited to add:</strong> If you are a heavy GA API user like me, it is worth pointing out that the field names you enter into GTM are not the API names (e.g. API <code>pageTitle</code> is just <code>title</code> in GTM). The <a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference">analytics.js field reference</a> has all of the applicable names.</p>
<p><strong>In short:</strong> don&#8217;t add UTM parameters to the URL in GTM; add campaign data directly to the pageview GTM sends to GA.</p>
<p>This was a puzzle because searching for help brought up so many irrelevant results. Hat tip to <a href="http://www.lunametrics.com/blog/2014/06/11/campaign-tracking-dynamic-source/">Lunametrics</a> for cracking it for me, once I finally found their post!</p>
<p>The post <a href="https://www.rweber.net/analytics/adding-url-parameters-google-tag-manager-dont-literal/">Adding URL parameters with Google Tag Manager: Don&#8217;t be too literal</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/analytics/adding-url-parameters-google-tag-manager-dont-literal/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">40095</post-id>	</item>
		<item>
		<title>Working with GA&#8217;s Enhanced Ecommerce (using GTM)</title>
		<link>https://www.rweber.net/analytics/ga-enhanced-ecommerce-using-gtm/</link>
					<comments>https://www.rweber.net/analytics/ga-enhanced-ecommerce-using-gtm/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 12 Dec 2016 13:00:25 +0000</pubDate>
				<category><![CDATA[Analytics]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Google Tag Manager]]></category>
		<category><![CDATA[jQuery]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39995</guid>

					<description><![CDATA[<div><img width="300" height="225" src="https://www.rweber.net/wp-content/uploads/2016/12/beach-east-frisia-300x225.jpg" class="attachment-medium size-medium wp-post-image" alt="beach sand in east frisia, by grafik_design on pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/12/beach-east-frisia-300x225.jpg 300w, https://www.rweber.net/wp-content/uploads/2016/12/beach-east-frisia-768x575.jpg 768w, https://www.rweber.net/wp-content/uploads/2016/12/beach-east-frisia.jpg 1024w, https://www.rweber.net/wp-content/uploads/2016/12/beach-east-frisia-150x112.jpg 150w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>An example of sending product impressions gradually, so your analytics data reflects actual visibility on the page.</p>
<p>The post <a href="https://www.rweber.net/analytics/ga-enhanced-ecommerce-using-gtm/">Working with GA&#8217;s Enhanced Ecommerce (using GTM)</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="225" src="https://www.rweber.net/wp-content/uploads/2016/12/beach-east-frisia-300x225.jpg" class="attachment-medium size-medium wp-post-image" alt="beach sand in east frisia, by grafik_design on pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/12/beach-east-frisia-300x225.jpg 300w, https://www.rweber.net/wp-content/uploads/2016/12/beach-east-frisia-768x575.jpg 768w, https://www.rweber.net/wp-content/uploads/2016/12/beach-east-frisia.jpg 1024w, https://www.rweber.net/wp-content/uploads/2016/12/beach-east-frisia-150x112.jpg 150w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>Google Analytics has a suite of Enhanced Ecommerce tools that let you see which products are getting viewed and clicked on in pages that aggregate them, such as category pages. It can include position so you can see how much of a boost it is to be first in line. There&#8217;s some work involved in setting this up, though, and I thought I&#8217;d record it for my own and others&#8217; reference.</p>
<p>The simplest way to do this is to push all of the products as one big group impression, which is how the <a href="https://developers.google.com/tag-manager/enhanced-ecommerce">Enhanced Ecommerce documentation</a> tells you to do it. We wanted to be more subtle, though, and use impressions to learn whether people were interacting with the page; i.e., to send impressions only when the products had actually been in view.</p>
<p>Let&#8217;s suppose three carousels of products for which we want to track impressions and clicks. I&#8217;ll assume a very simple carousel markup, where the items inside the carousel div are links that have <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes">data attributes</a> with all the product information. Throughout this I&#8217;ll be simplifying so that the core ideas aren&#8217;t muddied by syntax.</p>
<p><iframe src="//pastebin.com/embed_iframe/XSdquy1z" style="border:none;width:100%;height:375px;">View embedded code on the blog</iframe></p>
<p>I&#8217;m going to walk through the JavaScript top down. First, the document.ready call; inside it we keep track of which carousel panels have been visible on the visitor&#8217;s screen, and push product impression information for the visible products when a carousel is first scrolled into view or is clicked through on to a previously-unviewed panel. We also push product click information when a product is clicked on.</p>
<p>Each of our three carousels in this example has three panels. If the number of panels per carousel changes depending on the size of the viewer&#8217;s screen, you&#8217;ll want to put in some window size checks and adjust accordingly.</p>
<p><iframe src="//pastebin.com/embed_iframe/6FGQe6bk" style="border:none;width:100%;height:400px;"></iframe></p>
<p>What are those things being sent to the pushProductClick and pushProductImpressions functions? They are objects or arrays of objects, where the object properties are information about the product, which list it is in, and where in the list it occurs. I&#8217;ve used the namespacing syntax for a <a href="https://learn.jquery.com/plugins/basic-plugin-creation/">jQuery plugin</a> here (I&#8217;ll also point you to a short and sweet Stack Overflow about <a href="http://stackoverflow.com/questions/2398007/in-jquery-what-is-the-difference-between-myfunction-and-fn-myfunction">the difference between $.myFunction and $.fn.myFunction</a>).</p>
<p><iframe src="//pastebin.com/embed_iframe/1UJkL4U6" style="border:none;width:100%;height:400px;"></iframe></p>
<p>Finally, we have the push functions themselves, which take the product object or array and execute the appropriate dataLayer.push command. The product click push is more complex than the product impression push; one gotcha I ran into is that the productObj object must be enclosed in square brackets, despite being only a single thing. The eventCallback is typically a window.location, but if you set that, a visitor who tries to open a link in a new tab will also get it in the current tab. Making that a simple return statement and not preventing default in the click handler (above) allows the data to be sent to GA while also allowing the visitor to interact with the link in the way they choose.</p>
<p><iframe src="//pastebin.com/embed_iframe/WTB6JpBd" style="border:none;width:100%;height:400px;"></iframe></p>
<p>The Google Tag Manager side of the setup is pretty standard. It matches the setup in the <a href="https://developers.google.com/tag-manager/enhanced-ecommerce">Enhanced Ecommerce documentation</a> except for one detail: the trigger for the product impressions is not the event gtm.dom but the event productImpressions, mirroring the product click setup. You have to dig down a bit to get the data layer turned on, and <a href="https://www.simoahava.com/analytics/custom-event-listeners-gtm/">you can&#8217;t test it in preview mode</a>, unfortunately, but the GTM side is simple enough that it&#8217;s not too worrisome once you&#8217;ve console.debugged your way to confidence that your product objects and arrays are correct.</p>
<hr>
<p><small>Photo of beach sand on Baltrum Island, Germany by <a href="https://pixabay.com/en/beach-sand-wadden-sea-north-sea-988645/">grafik_design on Pixabay</a>.</small></p>
<p>The post <a href="https://www.rweber.net/analytics/ga-enhanced-ecommerce-using-gtm/">Working with GA&#8217;s Enhanced Ecommerce (using GTM)</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/analytics/ga-enhanced-ecommerce-using-gtm/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39995</post-id>	</item>
	</channel>
</rss>
