How to stop Google Tag Manager being hacked

In two high-profile data breaches this year – at Ticketmaster and British Airways – over half a million credit cards were stolen via a compromised script inserted on the payment pages. Google Tag Manager is a powerful tool which enables you to insert any script you want onto pages of your website, but that power can used against you by hackers if you're not careful – and below we’ll look at how to stop GTM being a security risk on your payment pages. Firstly, how did the hackers get the card details from these sites? And how is it relevant to GTM on your site? Security firm RiskIQ has traced the breach to a compromised Javascript file which skimmed the card details from the payment form. So when a user entered their credit card number and security code on BritishAirways.com (or their mobile app) those details were posted to a third party server, unknown to British Airways or the customer. This is a high-scale equivalent of placing a skimming devices on an ATM, which reads one card at a time. In Ticketmaster’s hack the script was one loaded from a chatbot vendor on their site, Inbenta. Inbenta claims not even to have been aware the script was used on payment pages. The changes to the script were subtle: not breaking any functionality, and in BA’s case using a domain ‘baway.com’ which looked somewhat authentic. To protect your site against a similar attack you obviously need to lock down accounts used by your developers to change scripts in the page source code, but you also need to secure GTM – which can be used to deploy such scripts. We have a few rules at Littledata to help reduce risks in using tag management on payment pages: 1. Use pixels over custom JavaScript tags on payment pages You probably need a few standard tags, such as Google Analytics, on payment pages but try to avoid any custom scripts which could possibly skim card details. Many non-standard tags use JavaScript only to create the URL of a tracking pixel – and it is much safer (and faster) to call the tracking pixel directly. Contact the vendor to find out how. (Littledata's Shopify app even removes the need to have any script on the payment pages, by hooking into the order as it's registered on Shopify's servers) 2. Avoid loading external JavaScript files in GTM Many vendors want you to load a file from their server (e.g. myvendor.com/tracking.js) from GTM, so they can update the tracking code whenever they want. This is flexible for them, but risky for you. If the vendor gets hacked (e.g. with Inbenta above) then you get compromised. It’s less risky to embed that script directly in GTM, and control version changes from there (although a fraction slower to load the page). Of particular risk is embedding a tag manager within a tag manager – where you are giving the third party rights to publish any other scripts within the one tag. Don’t do that! 3. Lock down Edit and Publish rights on GTM Your organisation probably has a high turnover of contract web developers and agencies, so have you checked that only the current staff or agencies have permission to edit and publish? It's OK to have external editors use 'workspaces' for version control in GTM, but ideally someone with direct accountability to your company should check and Publish. 4. Blacklist custom JavaScript tag on the payment pages You can set a blacklist from the on-page data layer to prevent certain types of tags being deployed on the payment pages. If you have a GTM container with many users, this may be more practical that step 3. 5. Remove tags from old vendors There are many thousands of marketing tools out there, and your company has probably tried a few. Do you remove all the tags from vendors when you stop working with them? These are most at risk of being hacked. At Littledata we run a quarterly process for marketing stakeholders opt-in tags they still need for tracking or optimisation. 6. Ensure all custom JavaScript tags are reviewed by a developer before publishing It can be hard to review minimised JavaScript libraries, but worth it for payment pages if you can’t follow rules 1 and 2. If you’re still worried, you can audit the actual network requests sent from payment pages. For example, in Chrome developer tools, in the 'Network' tab, you can inspect what requests sent out by the browser and to what servers. It’s easy for malicious code to hide in the patchwork of JavaScript that powers most modern web experiences, but what is harder to hide is the network requests made from the browser to external servers (i.e. to post the stolen card information out). This request to Google Analytics is fine, but if the domain of a request is dubious, look it up or ask around the team. Good luck, and keep safe with GTM!

2018-11-24

6 reasons Facebook ads don’t match the data you see in Google Analytics

If you run Facebook Ads and want to see how they perform in Google Analytics, you may have noticed some big discrepancies between the data available in Facebook Ad Manager and GA. Both systems use different ways to track clicks and visitors, so let’s unpick where the differences are. There are two kinds of metrics you’ll be interested in: ‘website clicks’ = the number of Facebook users who clicked on an advert on your own site, and (if you do ecommerce) the transaction value which was attributed to that advert. Website Clicks vs Sessions from Facebook 1. GA isn’t picking up Facebook as the referrer If users click on a link in Facebook’s mobile app and your website opens in an in-app browser, the browser may not log that ‘facebook.com’ was the referrer. You can override this (and any other link) by setting the medium, source, campaign and content attributes in the link directly. e.g. www.mysite.com?utm_medium=social&utm_source=facebook.com&utm_campaign=ad Pro Tip: you can use GA’s URL builder to set the UTM tags on every Facebook campaign link for GA. In GA, under the Admin tag and then ‘Property settings’ you should also tick the box saying ‘Allow manual tagging (UTM values) to override auto-tagging (GCLID values)’ to make this work more reliably. 2. The user leaves the page before the GA tag fires There’s a time delay between a user clicking on the advert in Facebook and being directed to your site. On a mobile, this delay may be several seconds long, and during the delay, the user will think about going back to safety (Facebook’s app) or just closing the app entirely. This will happen more often if the visitor is not familiar with your brand, and also when the page contents are slow to load. By Facebook’s estimation the GA tracking won’t fire anywhere between 10% and 80% of clicks on a mobile, but fewer than 5% of clicks on a desktop. It depends on what stage in the page load the GA pixel is requested. If you use a tag manager, you can control this firing order – so try firing the tag as a top priority and when the tag container is first loaded. Pro Tip: you can also use Google's mobile site speed suggestions to improve mobile load speed, and reduce this post-click drop-off. 3. A Javascript bug is preventing GA receiving data from in-app browsers It’s possible your page has a specific problem that prevents the GA tag firing only for mobile Safari (or Android equivalent). You’ll need to get your developers to test out the landing pages specifically from Facebook’s app. Luckily Facebook Ad Manager has a good way to preview the adverts on your mobile. Facebook Revenue vs GA Ecommerce revenue 4. Attribution: post-click vs last non-direct click Currently, Facebook has two types of attribution: post-view and post-click. This means any sale the user makes after viewing the advert or clicking on the advert, within the attribution window (typically 28 days after clicking and 1 day after viewing), is attributed to that advert. GA, by contrast, can use a variety of attribution models, the default being last non-direct click. This means that if the user clicks on an advert and on the same device buys something within the attribution window (typically 30 days), it will be attributed to Facebook.  GA doesn't know about views of the advert. If another campaign brings the same user to your site between the Facebook ad engagement and the purchase, this other campaign takes the credit as the ‘last non-direct click’. So to match as closely as possible we recommend setting the attribution window to be '28 days after clicking the ad' and no 'after view' attribution in Facebook (see screenshot above) and then creating a custom attribution model in GA, with the lookback window at 28 days, and the attribution 'linear' The differences typically come when: a user engages with more than one Facebook campaign (e.g. a brand campaign and a re-targeting one) where the revenue will only be counted against the last campaign (with a priority for ads clicked vs viewed) a user clicks on a Facebook ad, but then clicks on another advert (maybe Adwords) before buying. Facebook doesn’t know about this 2nd advert, so will attribute all the revenue to the Facebook ad. GA knows better, and will attribute all (or part) of it to Adwords. 5. Facebook cross-device tracking The main advantage Facebook has over GA is that users log in to its platform across all of their devices, so it can stitch together the view of a mobile advert on day 1 with a purchase made from the user’s desktop computer on day 2. Here’s a fuller explanation. By contrast, unless that user logs into your website on both devices, and you have cross-device tracking setup, GA won’t attribute the sale to Facebook. 6. Date of click vs date of purchase In Facebook, revenue is attributed to the date the user saw the advert; in GA it is to the date of purchase. So if a user clicks on the advert on 1st September, and then buys on the 3rd September, this will appear on the 1st on Facebook – and on the 3rd in GA. 7. The sampling problem Finally, did you check if the GA report is sampled? In the top right of the screen, in the grey bar, you'll see that the report is based on a sample.  If that sample is less than 100% it means the numbers you see are estimates.  The smaller the sample size used, the larger the possibility of error.  So in this example, a 45% sample of 270,000 sessions could skew our results plus or minus 0.2% in the best case. As a rule of thumb, Google applies sampling when looking over more than 500,000 sessions (even if you select the 'greater precision' option from the drop-down menu). You can check your own sample using this confidence interval calculator. Conclusion Altogether, there’s a formidable list of reasons why the data will never be an exact match, but I hope it gives you a way to optimise the tracking. Please let us know if you’ve seen other tracking issues aside from these.   Get Social! Follow us on LinkedIn, Twitter, and Facebook and keep up-to-date with our Google Analytics insights.

2017-02-08

Cross Domain tracking for Eventbrite using Google Tag Manager (GTM)

Are you using Eventbrite for event registrations? And would you like to see the marketing campaign which drove that event registration correctly attributed in Google Analytics? Then you've come to right place! Here is a simple guide to adding a Google Tag Manager tag to ensure the correct data is sent to Eventbrite to enable cross-domain tracking with your own website. Many thanks to the Lunametrics blog for their detailed solution, which we have adapted here for GTM. Before this will work you need to have: links from your site to Eventbrite (including mysite.eventbrite.com or www.eventbrite.co.uk) the Universal Analytics tracking code on both your site and your Eventbrite pages. only have one GA tracking code on your own site - or else see the Lunametrics article to cope with this 1. Create a new tag in GTM Create a new custom HTML tag in GTM and paste this script: [code language="javascript"] <script> (function(document, window) { //Uses the first GA tracker registered, which is fine for 99.9% of users. //won't work for browsers older than IE8 if (!document.querySelector) return; var gaName = window.GoogleAnalyticsObject || "ga" ; // Safely instantiate our GA queue. window[gaName]=window[gaName]||function(){(window[gaName].q=window[gaName].q||[]).push(arguments)};window[gaName].l=+new Date; window[gaName](function() { // Defer to the back of the queue if no tracker is ready if (!ga.getAll().length) { window[gaName](bindUrls); } else bindUrls(); }); function bindUrls() { var urls = document.querySelectorAll("a"); var eventbrite = /eventbrite\./ var url, i; for (i = 0; i < urls.length; i++) { url = urls[i]; if (eventbrite.test(url.hostname) === true) { //only fetches clientID if this page has Eventbrite links var clientId = getClientId(); var parameter = "_eboga=" + clientId; // If we're in debug mode and can't find a client if (!clientId) { window.console && window.console.error("GTM Eventbrite Cross Domain: Unable to detect Client ID. Verify you are using Universal Analytics."); break; return; } url.search = url.search ? url.search + "&" + parameter : "?" + parameter; } } } function getClientId() { var trackers = window[gaName].getAll(); return trackers[0].get("clientId"); } })(document, window); </script> [/code]   2. Set the tag to fire 'DOM ready' Create a new trigger (if you don't have a suitable one) to fire the tag on every page at the DOM ready stage.  We need to make sure the Google Analytics tracker has loaded first. 3. Test the marketing attribution With the script working you should see pageviews of the Eventbrite pages as a continuation of the same session. You can test this by: Opening the 'real time' reporting tag in Google Analytics, on an unfiltered view Searching for your own site in Google Navigating to the page with the Eventbrite link and clicking on it Looking under the Traffic Sources report and checking you are still listed as organic search after viewing the Eventbrite page Need more help? Comment below or get in touch!   Get Social! Follow us on LinkedIn, Twitter, and Facebook and keep up-to-date with our Google Analytics insights.

2017-02-07

3 reasons why you should use Google Tag Manager

If you have an online presence you know that every day you find new and interesting app's and platforms that can increase your revenue. From integrations with Adwords, DoubleClick, Facebook to custom plugins, you need some help inserting all this script in the page that makes it as easy as possible and without asking for developer help. Google Tag Manager can launch new tags with just a few clicks. Google Tag Manager supports both Google and third-party tags and is the web’s most popular enterprise-grade tag management solution. We have written a lot or articles on how to use it, but we never provided a list of why you should use it, so here it is: 1. Reliable and accurate data. When your tags aren’t working properly they can impair your site performance, resulting in slow load times, website unavailability, or a loss of functionality. That’s why it’s critical to have a tag management solution in place that allows you to quickly determine the status of your tags. Easy-to-use error checking and speedy tag loading in Google Tag Manager means you know that every tag works. Be assured that your mission-critical data is being collected reliably and accurately. The IT team will feel confident that the site is running smoothly, so everyone's happy, even during busy holidays or the launch of a new campaign. Large brands have implemented Tag Manager to launch their tags exactly for this reason: reliable and accurate data. PizzaHut, Made.com, AgeUk and many others use Google Tag Manager to manage their tags for Google and third-party platforms. 2. Quickly deploy Google and third-party tags. With so many measurement tools out there, marketers need flexibility — whether that’s changing tags on the fly or having the ability to easily add tags from other sources. In Google Tag Manager, marketers can add or change their own tags as needed. Google Tag Manager supports all tags and has easy-to-use templates for a wide range of Google and third-party tags — for web and mobile apps. Don’t see a tag listed? You can add it immediately as a custom tag. With so much flexibility, your campaign can be underway with just a few clicks. Even if you are using Adwords, Adroll, Facebook, Hotjar, Criteo or your own script you can implement it with Google Tag Manager. Even if you're a publisher as nationalgeographic-magazine.com, sell furniture at Made.com, sell event tickets as eventbrite.com or organise courses as redcrossfirstaidtraining.co.uk, Google Tag Manager will be the best way to organise all the scripts your partners provides. 3. Collaborate across the enterprise and make tag updates efficiently. Collaboration across a large team can be a challenge. Not having the proper tools can stall workflows — decreasing productivity and efficiency. Workspaces and granular access controls allow your team to work together efficiently within Google Tag Manager. Multiple users can complete tagging updates at the same time and publish changes as they’re ready. Multi-environment testing lets you publish to different environments to ensure things are working as expected. I don't know about you but for me, every time I need to add a new script on my website I hesitate because I am afraid that my website will break and I would never know how to fix it. I wanted a solution where I could add a script on my own, test it and then publish it without any developer help. And then I found Google Tag Manager. Google Tag Manager lets you collaborate and work independently, at the same time, on the same website. You can publish a tag at the same time your marketing team-mate is creating an A/B testing experiment, all in the same GTM container. Large and small websites use Google Tag Manager to integrate and increase the value of their website. It is free, it is reliable and you find a lot of how-tos on the web so you can start using it right away. Google Tag Manager currently provides out-of-the-box integration with these ones: Universal Analytics - Google Analytics Classic Google Analytics - Google Analytics AdWords Conversion Tracking - AdWords AdWords Remarketing - AdWords DoubleClick Floodlight Counter - DoubleClick DoubleClick Floodlight Sales - DoubleClick Google Optimize - Google Optimize Google Surveys Website Satisfaction - Google Surveys AB TASTY Generic Tag Adometry AdRoll Affiliate Window Affiliate Window Audience Center 360 Bizrate Insights ClickTale comScore Crazy Egg Criteo Dstillery Eulerian Analytics Google Trusted Stores Hotjar Infinity Tracking Intent Media K50 LeadLab by wiredminds LinkedIn Marin Software Mediaplex Microsoft Bing Ads Mouseflow Neustar Nielsen Nudge Content Analytics Optimise Media OwnerListens Perfect Audience Personali Placed Inc. Pulse Insights Quantcast SaleCycle SearchForce Shareaholic Survicate Tradedoubler Turn Twitter Ve Interactive VisualDNA Yieldify This out-of-the-box integration doesn't require any special knowledge. And, for any other script that you might have, most of the providers have a how-to guide for integrating with Google Tag Manager. Have any questions about Google Tag Manager? Get in touch with our experts!   Get Social! Follow us on LinkedIn, Twitter, and Facebook and keep up-to-date with our Google Analytics insights.

2016-12-13

How to set up ecommerce tracking with Google Tag Manager

Enhanced ecommerce tracking requires your developers to send lots of extra product and checkout information in a way that Google Analytics can understand. If you already use GTM to track pageviews you must send ecommerce data via Google Tag Manager Step 1 Enable enhanced ecommerce reporting in the Google Analytics view admin setting, under 'Ecommerce Settings' Step 2 Select names for your checkout steps (see point 4 below): Step 3 Get your developers to push the product data behind the scenes to the page 'dataLayer'. Here is the developer guide. Step 4 Make sure the following steps are tracked as a pageview or event, and for each step set up a Universal Analytics tracking tag: Product impressions (typically a category or listing page) Product detail view (the product page) Add to basket (more usually an event than a page) Checkout step 1 (views the checkout page) Checkout step 2 etc - whatever registration, shipping or tax steps you have Purchase confirmation Step 5 Edit each tag, and under 'More Settings' section, select the 'Enable enhanced ecommerce features' and then 'use data layer' options: Of course, there's often a bit of fiddling to get the data layer in the right format, and the ecommerce events fires at the right time, so please contact us if you need more help setting up the reports! Step 6 - Checking it is working There is no 'real time' ecommerce reporting yet, so you'll need to wait a day for events to process and then view the shopping behaviour and checkout behaviour reports. If you want to check the checkout options you'll need to set up a custom report: use 'checkout options' as the dimension and 'sessions' and 'transactions' as the metrics. Need some more help? Get in touch with our lovely team of experts and we'd be happy to answer any questions!   Get Social! Follow us on LinkedIn, Twitter, and Facebook and keep up-to-date with our Google Analytics insights.  

2016-11-10

New interface and workspaces in Google Tag Manager

Google Tag Manager has recently had quite a revamp to its interface. Not to mention the addition of much talked about workspaces feature. Google Tag Manager (GTM) is a great tool that saves the development and implementation time, and the new drastic changes in any of Google’s tools can be quite a shock when you’re used to one way of workflow. The latest changes to the interface are radical but as with everything else, it just takes a short while to get used to. GTM still works the same, though. There’s no change to how your tags, triggers and variables are set up. So let’s see what's changed! Overlays on top of overlays This is the biggest change in the interface! Whether you’re creating a new tag or changing an existing one, you’ll be making your updates in overlays that slide in from the right hand side of the screen. Whilst this may be confusing initially, this is a great improvement on the previous workflow. Before you had to create your variables before the tag, or if creating the tag, save the progress, then create the variable separately, and then return to the tag to add in your variable. Too many steps! The new overlay doesn’t cover the whole screen and instead, leaves a bit of space on the left so you can see where you started from. Now that I’ve embraced the workspaces, I’ve realised how great it is to be able to do changes and updates without navigating elsewhere. Icons replace colours Previously, when viewing a list of tags all the triggers were colour coded so you could quickly see types of triggers used. Now, they’re all grey with icons at the beginning. I’ve previously found the colour coding very handy in quickly determining where the tags have been set to work. I’m not convinced that the icons will do as great of a job, but like with all of the changes – just embrace them and move on. List of variables They’ve lost the ‘enabled built-in variables’ section at the top. It used to have checkboxes so you could quickly enable or disable select variables. Now you have a list of built-in variables and for any changes, you have to click ‘configure’ button and then select which ones you want or not. And of course, you’ll have to do these changes in the overlay that slides over. The variables you've created previously will be in a separate list when you scroll down the page. If you want to view the details of the variable, then you’ll have to click on the variable and see its setup in the new overlay. Remember, remember… Do you tend to forget to specify your container's name and description? Now you get reminded to do so when you click to ‘publish’ your container and haven’t set the details. Timestamps I love it when a small change can make a big difference! This is that kind of change. When hovering over any relative timestamps in the triggers, overview or other sections, you will see the exact date and time of the latest change. What are workspaces? Workspaces are multiple containers that teams and users can work on without worrying about publishing someone else’s updates that may not be ready to go live. For someone working within a number of teams, like we do, this is a very welcomed update. After using it for a few weeks, I’ve already seen improvements in the speed of publishing updates. Now, fewer people have been blocked from progressing on their tags, which is really great! So now you can make your additions or amendments in a separate space and publish them when they're ready. What really happens when you publish is that anything new in your workspace gets added to the default workspace. This may include any updates to tags, triggers, variables, and any notes you may have added. If you can, stick to making smaller sets of changes within workspaces so you have a more robust version history, allowing you to trace updates and roll back to previous versions more quickly. You’ll get 3 workspaces in total so 1 default one + 2 custom workspaces, whilst 360 accounts get unlimited workspaces. Here’s how they work. To create a separate workspace click on the ‘Default Workspace’ in the left panel. In the new overlay click on the + icon in the top right corner. Now enter the name and description for the workspace so when you choose a workspace you can quickly see what's being worked on in there, or what the purpose of the workspace is. You can always refer to these for information on what was worked on or published as part of this workspace. A new workspace will always be created based on the latest GTM version and include the latest tags, triggers, and variables. If you're publishing a workspace that has conflicting updates with another workspace, then GTM will let you know and give you the option to resolve conflicts in their very easy to use conflict resolution tool. Once you publish the non-default workspace, it will be automatically removed. Better tag management You know how GTM has a number of tag templates for the most typical tracking needs, for example, AdWords and DoubleClick. These templates are very useful for creating and maintaining tags without codes, allowing to insert only required data, and making the whole process less error-prone. Well, they've expanded their selection with additional templates from vendors such as Bing, Twitter, Hotjar, Nielsen, Yieldify and many many more. I've been setting up a number of tags from the new vendors so I'm glad to see they've finally caught up with this. Here's a full list of supported tags is available in Tag Manager's Help section.   So these are some of the most notable changes. My favourite ones are overlays, timestamps and workspaces for reasons I mentioned above. The overlays don't seem to have got much love when they were first launched, but it's definitely a step up on the previous workflow. Got strong feelings about any of the latest updates? Let me know what you love or hate in the comments below.   Get Social! Follow us on LinkedIn, Twitter, and Facebook and keep up-to-date with our Google Analytics insights.   Image credit: screenshot of 'conflict resolution tool' courtesy of Google Analytics Blog

2016-10-13

How to track forms which don't redirect to a thank you page

Many contact forms now use Javascript to submit and do not redirect to a new page. So to track the form, unless you trigger an event on the submit button, you need to listen for a piece of text (usually saying thank you). We have created a custom HTML script that listens to the changes in the page and triggers an event called 'formSubmitted'. This event can then be used to fire a separate tag with event details to Google Analytics. We've tested this on our contact form at Littledata and here's how you can set it up too. Step 1 The first step is to go through the contact form and see what the steps are in completing it. On ours, you just enter the information in the fields and press "SUBMIT MESSAGE". When the message is sent out, the button will say "SENT!". Here the only thing that changed was the text on the button from 'submit message' to 'sent'. We built this HTML script that listens to the changes on the page, but you'll need to change line 10 to be whatever the message is in your form. You will also need to change line 15 if you have multiple forms on the page. [code lang="js"] &lt;script&gt; // **** Littledata Javascript form tracker **** // Generates a GTM custom event called 'formSubmitted' // When an on-page form is submitted // CHANGE the text to match the message displayed // when the form is successfully completed // It is not case sensitive var text = "sent!" // By default it will search for text within the first form // Set to false if text is outside a form // or change to a higher false if there are multiple forms var formIndex = 0; // OPTIONALLY, restrict the search to an HTML element ID // If you leave this blank, the whole page will be searched; // this causes the script to run more slowly var targetId = "" // **** No changes needed to the script below **** text = text.toLowerCase() dataLayer = dataLayer || []; if (!formIndex &amp;&amp; targetId.length == 0) console.error('Form tracker needs either a form or an element ID') var checkEveryMilliseconds = 500; formTrackerInterval = window.setInterval(function(){ var target = "" if (formIndex &gt;= 0) { var form = document.getElementsByTagName('form') target = (form.length &gt; 0) ? form[formIndex].textContent : ""; } else target = document.getElementById(targetId).textContent target = target.toLowerCase() if (target.indexOf(text) &gt; -1) { window.clearInterval(formTrackerInterval); dataLayer.push({ event: 'formSubmitted' }) } },checkEveryMilliseconds) &lt;/script&gt; [/code] Step 2 Now we need to add the script to listen out for when the form is submitted. Create a custom HTML tag in your GTM container. You can name the tag 'LISTENER Contact form submit event' or anything else you will remember it by. Choose the tag type 'Custom HTML'. Copy and paste your HTML/Javascript into the textbox, and remember to change the var text (line 10) with your own text. Step 3 This tag needs a firing trigger, specifying the rules when it needs to be activated. If you can, only fire on specific pages - the script will slow down the page a little, as it runs every half a second to check the form. Give the trigger a descriptive name - here I've chosen "PAGE About us" Select trigger type as 'Custom Event' and for the event name put " gtm.load ", which means this trigger at page load. We want this trigger to work on a specific page only, so the firing rule goes 'page path equals /about-us', which means that our trigger will work on the www.littledata.io/about-us page only. If you have a number of pages that have the form you're tracking, then you could use 'contains' rule and select part of the link that is applicable to all. For example, if all of your links have word 'contact' in them, then your firing rule would say 'page path contains contact'. Step 4 Now that you have your listener tag set up, you need to create a separate tag to send the event details to Google Analytics. Again, give it a descriptive name so you know what it's for - here I've used 'GA event - contact form submitted'. Select tag type as 'Universal Analytics' and in the tracking ID field, select the variable that contains your GA tracking id. For event category, action and label you have to specify the namings by which this data will be categorised in Google Analytics. Step 5 This tag needs its own trigger to know when to fire, and here you have to use the event created by the listener tag set up during steps 2-3. Here you have to specify that this tag can only fire when event 'formSubmitted' happens. I've called my trigger 'Contact form event', selected trigger type as 'custom event' and entered event name 'formSubmitted. Now you can save it and test in the debugger mode. Try submitting your contact form and see if the event 'formSubmitted' appears. You should also see the tag 'GA event - contact form submitted' fire. If everything's ok, publish the container and do a final test. Make a new form submission and check if you can see the event details come through in Google Analytics real time reports, under events. Need some help setting this up or Google Tag Manger? Why not get in touch by contacting our lovely Google Analytics experts?   Get Social! Follow us on LinkedIn, Twitter, and Facebook and keep up-to-date with our Google Analytics insights. Further reading: How to set up event tracking in Google Tag Manager Why should you tag your campaigns? Set up Ecommerce tracking with Google Tag Manager

2016-10-11

Personally Identifiable Information (PII), hashing and Google Analytics

Google has a strict policy prohibiting sending Personally Identifiable Information (PII) to Google Analytics. This is necessary to provide GA reports around the world, yet comply with country regulations about storing personal information.  Even if you send personal information accidentally, Google may be forced to delete all of your analytics data for the time range affected. This policy has recently tightened to state: You may not upload any data that allows Google to personally identify an individual (such as names and email addresses), even in hashed form. A number of our clients are using a hashed email as the unique identifier for logged in users, or those coming from email campaigns.  If so, this needs be a minimum of SHA256 hashing (not MD5 hashing), with a 'salt' to improve the security - check your implementation meets the required standard. If you want to check if personal information affects your analytics, we now include checking for PII in our complete Google Analytics audit. Google's best practice for avoiding this issue is to remove the PII at the source - on the page, before it is sent to Google Analytics.  But it may be hard to hunt down all the situations where you accidentally send personal data; for example, a form which sends the user's email in the postback URL, or a marketing campaign which add the postcode as a campaign tag. We have developed a tag manager variable that does this removal for you, to avoid having to change any forms or marketing campaigns which are currency breaking the rules. Steps to setup 1. Copy the script below into a new custom Javascript variable in GTM [code language="javascript"]function() { // Modify the object below to add additional regular expressions var piiRegex = { //matches emails, postcodes and phone numbers where they start or end with a space //or a comma, ampersand, backslash or equals "email": /[\s&amp;\/,=]([a-zA-Z0-9_.+-]+\@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)($|[\s&amp;\/,])/, "postcode": /[\s&amp;\/,=]([A-Z]{1,2}[0-9][0-9A-Z]?(\s|%20)[0-9][A-Z]{2})($|[\s&amp;\/,])/, "phone number": /[\s&amp;\/,=](0[0-9]{3,5}(\s|%20)?[0-9]{5,8}|[0-9]{3}-[0-9]{4}-[0-9]{4})($|[\s&amp;\/,])/ }; // Ensure that {{Page URL}} is updated to match the Variable in your // GTM container to retrieve the full URL var dl = {{Page URL}} var dlRemoved = dl; for (key in piiRegex) { dlRemoved = dlRemoved.replace(piiRegex[key], 'REMOVED'); } return dlRemoved; }[/code]   2.Check {{Page URL}} is set up in your GTM container This is a built-in variable, but you'll need to check it under the variables tab.   3. Change the pageview tag to override the standard document location, and use the variable with PII removed   By default, Google Analytics takes the location to be whatever is in the URL bar (document.location in Javascript).  You will over-ride that with the PII-safe variable.  

2016-08-03

Why do you need cross-domain tracking?

What is cross-domain tracking and why do you need to implement in your Google Analytics account? Cross-domain tracking makes it possible for Analytics to see sessions on two related sites (such as an ecommerce site and a separate shopping cart site) as a single session. This is sometimes called site linking. Cross-domain literally means that you are able to see a user in a single Google Analytics account in his journey across multiple domains that you control (e.g. mysite.com and myshoppingcart.com). In the standard configuration of the Google Analytics script, every time a customer loads a page on a different domain a new session is generated, even if the branding looks seamless to the user and, unfortunately, the previous session has ended and this is even if the customer is still active and generates events and page views. Until you have implemented the cross-domain setting on your website you will not be able to have an accurate customer journey. Why? Let’s take, for example, a standard website, www.siteA.com, and it's blog, www.blogB.com. To track sessions, Analytics collects a client ID value in every hit. Client ID values are stored in 1st party cookies, and these cookies are only available to web pages on the same domain. When tracking sessions across multiple domains, the client ID value has to be transferred from one domain to the other. To do this, the Analytics tracking code has linking features that allow the source domain to place the client ID in the link URL, where the destination domain can access it. Fortunately, with the release of Universal Analytics cross-domain tracking, it is easier to implement, and especially so with Google Tag Manager. Setting up cross-domain tracking using Google Tag Manager Add (or edit your existing) a basic page tracking tag (i.e. Tag Type = Universal Analytics; Track Type = Page View). If you are using the same container for siteA.com and blogB.com, under More Settings → Fields to Set, enter the following: Field Name: allowLinker Value: true Under More settings → Cross-Domain Tracking → Auto Link Domains enter "blogB.com" (without the quotes). If you have multiple domains, separate them by commas: blogB.com, siteC.com Leave the 'Use hash as delimiter' and 'Decorate forms' unless you have an unusual web setup. Set the trigger to "All Pages". Save a version of the container and publish it. If you are using a separate container for blogB.com, repeat the steps above but in the Auto Link Domains field add: siteA.com Add both domains to the Referral Exclusion List When a user journey crosses from your first domain to your second domain, it will still appear as a new session in Google Analytics by default. If you want to be able to track a single session across multiple domains, you need to add your domains to the referral exclusion list. Here’s an example Tag Assistant Recordings report that shows what it looks like when cross-domain tracking is not setup properly. Setting up cross-domain tracking by directly modifying the tracking code To set up cross-domain tracking for multiple top-level domains, you need to modify the Google Analytics tracking code on each domain. You should have basic knowledge of HTML and JavaScript or work with a developer to set up cross-domain tracking. The examples in this article use the Universal Analytics tracking code snippet (analytics.js). Editing the tracking code for the primary domain ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true}); ga('require', 'linker'); ga('linker:autoLink', ['siteB.com'] ); Remember to replace the example tracking ID (UA-XXXXXX-Y) with your own tracking ID, and replace the example autoLink domain (siteB.com) with your own secondary domain name. Editing the tracking code on the secondary domain ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true}); ga('require', 'linker'); ga('linker:autoLink', ['siteA.com'] ); Remember to replace the example tracking ID (UA-XXXXXX-Y) with your own tracking ID, and replace the example autoLink domain (siteA.com) with your own primary domain name. Adding the domain to page URLs using filters By default, Google Analytics only includes the page path and page title in page reports - not the domains name. For example, you might see one page appear in the Site Content report like this: /contactUs.html Because the domain names aren’t listed, it might be hard to tell whether this is www.siteA.com/contactUs.html or www.blogB.com/contactUs.html. To get the domain names to appear in your reports you need to do two things: Create a copy of your reporting view that includes data from all your domains in it Add an advanced filter to that new view. The filter will tell Google Analytics to display domain names in your reports. Follow this example to set up a view filter that displays domain names in your reports when you have cross-domain tracking set up. For some fields, you need to select an item from the dropdown menu. For others, you need to input the characters here: Filter Type: Custom filter > Advanced Field A: Hostname Extract A: (.*) Field B: Request URI Extract: (.*) Output To: Request URI Constructor: $A1$B1 Click Save to create the filter. You can validate that filters are working as you expect using Google Tag Assistant Recordings. Tag Assistant Recordings can show you exactly how your filters change your traffic.   Get Social! Follow us on LinkedIn, Twitter, and Facebook and keep up-to-date with our Google Analytics insights.

2016-08-02

How to use the lookup table variable in Google Tag Manager

A lookup table in Google Tag Manager makes it much simpler to manage lots of values in your tracking setup. It can drastically reduce the number of tags required and turn your messy GTM into a neat environment. It's especially useful with larger setups where you have multiple tracking requirements and flexible to accommodate new tracking needs as they arise. You can easily add or remove values from your lookup tables, and not worry about having to change any codes. The lookup table variable allows you to define a set of key-value pairs where the output variable (the value that you are sending to Google Analytics) is linked to the identifier (the key). It works like this: When [input variable] equals to  _______, set [this output variable] to_______. For example, you could use the lookup table for: Assigning different Google Analytics property IDs for various domains/hostnames, eg. when [website hostname] equals to littledata.co.uk, set [property ID] to UA-010101 (see example below) Setting different pixel or conversions IDs for different country websites, eg when [website country code] equals to 2, set [pixel ID] to 88779 (requires having website country code variable defined) Defining your event categories, actions and labels (see example below) Remember! There’s no limit to how many values you can have in the lookup table, but the fields are case sensitive. So if you have multiple capitalisations of some input, then include all of them in the lookup table and assign the same output for each. I have previously explained setting up the tracking of user actions as events in GTM, but when you need to track multiple events, one tag just doesn't cut it anymore. And instead of creating several tags to cover each event or action, here's how you would create the lookup table to cover multiple values in one place. Creating lookup table variable for event parameters In the Littledata software interface, you get an option to switch between different report types or view them all. I want to track when people click on different report types, so instead of creating 5 different tags for each user action, I will set up a lookup table to cover all of them in one place. But firstly I need to know which variable to use as the input. You can only have one type of input variable per the lookup table so you want to pick a variable type that applies to each (ideally). For this, I will check how each report type option has been set up in the code by inspecting the element (inspect/inspect element depending on the browser you're using and usually accessible via right click). Here's how each report type has been set up: <a href="/report-list/m2i4MnmXcewDSzZ3c/all" class="current" id="ga-all">All <span class="count">120</span></a> <a href="/report-list/m2i4MnmXcewDSzZ3c/trends" class="" id="ga-trends">Trends <span class="count">80</span></a> <a href="/report-list/m2i4MnmXcewDSzZ3c/pages" class="" id="ga-pages">Pages <span class="count">37</span></a> <a href="/report-list/m2i4MnmXcewDSzZ3c/tips" class="" id="ga-tips">Tips <span class="count">3</span></a> <a href="/report-list/m2i4MnmXcewDSzZ3c/benchmark" class="" id="ga-benchmark">Benchmark <span class="count">0</span></a> Looking at the above, I can see that each report type has a unique ID - here that's the best one to use. Now to set this up, go to Variables, click ‘New’ and select 'Lookup Table' as your variable type. For the input variable, I will use {{Click ID}} as explained above, but you, of course, use whatever unique identifier you have available. For your output, you want to define the event action you are going to send to the Events report in Google Analytics. Should you set the default value? You can set a default value for the output when there is no match found in your table. With the event tracking, I sometimes find it useful to enable to identify if I set up my tag correctly. If my trigger ends up being too broad, the default value option will pick up additional values not defined in the table. I will then see these values in Google Analytics reports and this way I can tidy up the trigger to be more accurate. So this is what your variable should look like now. Click ‘Create Variable’ and there you have it. In your GA event tag, the newly created variable would look like this. Other uses Multiple Google Analytics properties If you have a single GTM container installed on multiple domains but you're tracking them across different Google Analytics properties, you want to ensure that you're sending the data to the correct one. Instead of having multiple variables to store different property IDs, you can have them all neatly in the same table defined by the hostname. This way any tracking activity on each site will go to its own dedicated property. Excluding test or other data If you want to make sure that any data outside of your main site goes to a test or other Google Analytics property, you can do so by setting the default value. The default value is the output that is not found in the table. With this setup, any activity tracked on www.mainsite.com goes to property ID UA-121212. If the activity wasn't on www.mainsite.com, then it sent to property ID UA-121212-2. Use lookup tables for something else? Confused? Get in touch or comment below!

2016-03-09

How to set up event tracking in Google Tag Manager

Events in Google Analytics are important for understanding how people interact with your website. They give you additional insight into their behaviour and how effective your pages are for leading users towards a conversion. With event tracking you could see how many users clicked on a button or played a video, scrolled down a page or clicked on your contact and social media icons. I mostly use Google Tag Manager (GTM) for analytics setup so I will show how to set up event tracking for clicks on buttons with GTM. Instead of hard coding events in the code, GTM allows you to create, test and amend tags within its interface. Before you go ahead creating your event tags, make sure your built-in pages and clicks variables are enabled. This will avoid you having to go back and forth between different sections. The setup below covers only one action - a click on a specific button - but if you have multiple actions to track, then look into implementing a lookup table variable. Tracking button clicks Here's my scenario. I want to track our BENCHMARK YOUR SITE button that allows users to sign up to our free software plan and get benchmarked against competitors.   And here's how to set it up. 1. Create a tag It will be a Universal Analytics tag type where tracking ID is a constant string variable (you need to create this variable before using it) and track type 'Event'. Think of your event tracking parameters as a way to organise the events into a hierarchy: Category – the main aim of the button or its placement Action – what the user clicked or the action Label – provides additional information like on what page the button was clicked or the outbound link they clicked on Value – if you have a numerical value to set for your click (not in my case tho) In my example, the category is ‘Get started’ because we have a number of similar buttons across the site with the same purpose to get the user started with the signup, so all of them have the same event category. For action, I specify the type of button that was clicked on so I can compare how these different buttons perform - 'Benchmark your site' in this case. My event label is the {{Page Path}} where they clicked on the button. The buttons take the user to the same place so I’m more interested in which pages these buttons were clicked on. Alternatively, if you have buttons that take people to different URLs you might want to track that instead. Is it a non-interaction hit? This is an important one to keep in mind. By default this is set to False. If you don’t want this event to impact your bounce rate, then change it to True, which you would do if the click or action didn’t take the user to the new page, or if you didn't want it to be included in your bounce rate calculations. Now click 'Continue' to go to the trigger setup. 2. Create a trigger Trigger is like a rule that allows you to tell the tag, ie specify the conditions, when it should fire. Under 'Fire On' select ‘Click’ as your trigger type and then ‘New’. For configuring the trigger, you have a choice between two types: Just Links – use this when the target is a link or anchor tag <a> All Elements – use this when the target is any other element that’s not a link To determine what’s best for your purposes you need to have a look at how your button is set up. You can do this by selecting ‘inspect element’ or simply ‘inspect’ depending on what browser you’re using. It’s usually available when you right click on the button or element.   Our button has been set up the following way: <a href="https://littledata.uk/signup" class="btn btn-ltd btn-green">benchmark your site</a> It has a link so I will use 'Just Links' for targets and I have a choice between three elements to use in further configuration: https://littledata.uk/signup as click url btn btn-ltd btn-green as click class benchmark your site as click text It is best to use a unique condition if you can. This way, if similar class or click url gets reused in other parts of the website you don't have to go back to this trigger to update it. With 'Just Links' you will get additional configuration options: Wait for tags - delays opening of links until all other tags have fired or the wait time has lapsed, whichever happens first Check validation - fires the tag only when opening the link was a valid action, without the tag will fire whenever the user clicks on the button/link Enable when - this options is shown only when either of the above is ticked so you can be specific about where you want the trigger to be active If you want the trigger to listen to the interactions on all pages, then set that section to be  URL or Page Path matches regex .*. (without that very last full stop - that one's for the sentence) In my case, I only want it to work on benchmark pages and all of them start with /benchmark/. The very last step in trigger setup is specifying on which actions or clicks the tag should fire. As said above, I'm using the button's click class here. All done? This is what your tag should now look like. Click 'Create Tag'. 3. Test Test your tag in GTM's preview mode by checking two things: the tag fires in the preview interface, and the tag is seen in Google Analytics real time view under 'Events' with the event parameters you specified   I hope you got on with the setup above just fine, but if you have questions or clarifications, feel free to ask below.   Further reading: Know who converts on your site with Google Analytics goals Using lookup table variable in Google Tag Manager Intro to Google Tag Manager's key concepts and terminology Image: Courtesy of suphakit73 at FreeDigitalPhotos.net  

2016-03-02

How to set up demographics and interests reports in Google Analytics

Demographics and interests reports in Google Analytics give you additional insight about your users, allowing you to do analysis based on age, gender and interest categories. You get a much better idea of who your users are and the setup is so quick to do, there's no reason not to. To get this information, you need to do minor tweaks to your Google Analytics and Google Tag Manager. Those changes will allow Google to share anonymised data about your site or app visitors, and once set up, you can use this information to understand the behaviour patterns of your users by different profiles. You will be able to see: If a particular age group converts more Whether you get more visits from males or females from a particular country or city If your users are more into travelling, movies or social media You'll also be able to: Build remarketing lists Build segments for more detailed information about your users Target your ads to specific users What reports will you get? Demographics Overview: snapshot view of your users by age and gender Age: Acquisition, Behaviour and Conversions metrics by age group (below 18 are not included) Gender: Acquisition, Behavior and Conversions metrics by gender Interests Overview: top 10 interests of your users in 3 areas: Affinity Categories, In-Market Segments and Other Categories Affinity Categories (reach): view of users by their lifestyle with Acquisition, Behaviour and Conversions metrics broken down by Affinity Categories In-Market Segments: view of users by their product-purchasing interests with Acquisition, Behaviour and Conversions metrics broken down by In-Market Segments Other Categories: more specific view of users with Acquisition, Behaviour and Conversions metrics broken down by Other Categories How does Google get this data? Google collects demographics and interests data from the third-party DoubleClick cookie for web traffic and anonymous identifiers for mobile app activity, like the Android Advertising ID and the iOS Identifier for Advertisers. But Google is unable to collect this data if the cookie or anonymous identifier isn't present, or if there's no profile information available. As a result, this data may only be available for a subset of your users. This will be shown on the report as a % of traffic the report represents. When is threshold applied? There are occasions when data is withheld from your reports to ensure the anonymity of users. For example, this might happen when you don’t have enough data for a particular age range or gender. When the threshold has been applied, you will see a notification below the report title. 3 simple steps to set this up 1. Enable the feature in Google Analytics Go to Admin > Property > Property Settings. Scroll down to Advertising Features, and set the option to Enable Demographics and Interests Reports to ON. Now save. 2. Enable the feature in Google Tag Manager Go to edit your GA pageview tag > Configure Tag. Under the tracking ID, tick the Enable Display Advertising Features box. Save the tag, and you've got one last step to do. 3. Enable the report in Google Analytics For this go to Audience > Demographics > Overview report. Click Enable, and you're all set. You should see your demographics and interests data within 24 hours of enabling the feature. We also provide consultancy services if you need help with more advanced setup.   Further reading: Tracking registered users with Google Analytics and GTM V2 How to use demographic targeting in AdWords  

2015-12-18

How to track registered users with Google Analytics and Google Tag Manager V2

Wondering if Samsung Galaxy is more popular than iPhone when engaging with your content? Then set up the User-ID view to see your logged in users’ activity and evaluate behaviour by the device. With the activity data you collect in the registered users view, you can improve the analysis of your customers' behaviour by seeing which devices are used to sign up and access your website. To summarise the benefits: You get access to the Cross-Device reports, which allow you to analyse which devices your users use to engage with your content. See what the Cross-Device reports look like. You improve your understanding of logged in users who often engage with the site's content differently than those who aren't registered. You get a more accurate user count. In your standard analytics view, a new user is counted every time your site visitor switches to a new device or starts a new session. With the registered user view, you give each user a unique ID, which helps to stitch together various activities carried out by the user. You can find out which devices users prefer for different engagement activities across multiple sessions. This helps with tailoring your campaign and content to different devices and activities. To set this up, you need to have the user ID stored in the data layer. If you don't have it set up, scroll to the bottom for an advanced hack. Now let’s look at how to set up the tracking by using Google Analytics and Google Tag Manager V2. Looking to implement the User-ID in your tracking code? Check Google’s guidance. Enable the feature in Google Analytics Firstly, enable the User-ID feature by going to  Admin > Property > Tracking info > User-ID. Read through the short policy on what you’re allowed to track and not. Google is very strict about tracking personally identifiable information so you are not allowed to send any personally identifiable information, such as names and email addresses. But numbered IDs or hashed emails are fine to use. To agree to the terms, follow the steps and click ‘create.’ Create the variable in Google Tag Manager Now go to GTM variables and click 'new'. Select Data Layer Variable type and use the name stored in your data layer, e.g. uid or user ID Add the variable to your pageview tag Go to edit your pageview tag and click on More settings > Fields to set. Click Add field, enter the field name as &uid and select the variable you’ve just created - eg {{uid}} or {{userID}}. Test you're seeing activity in the newly created registered users view with your login, or a test one if you have it. Don't forget to publish your GTM container for tracking to work. Advanced hack If for some reason you can't get your developer to store a user ID in the data layer, there is a way around it. We've created a javascript variable to get a username off the page and hash it prior to sending it to GA. For this, you need to pick a custom Javascript type variable and enter the script below into the custom javascript field. This javascript requires either your developer or you to customise it to work on your page (see the notes in the second and third lines). function() { //dependent on using Jquery selectors //replace '.menuTitle small a' with the selector for your username var name = $('.menuTitle small a').text(); var hash = 0, i, chr, len; if (name.length == 0) return hash; for (i = 0, len = name.length; i < len; i++) { chr = name.charCodeAt(i); hash = ((hash << 5) - hash) + chr; hash |= 0; // Convert to 32bit integer } return hash; }; If you need help with any of the above, don't hesitate to comment below or get in touch!

2015-08-19

Tracking web forms in Google Tag Manager V2

Do you know how many people start completing forms on your website, but don't complete them? Do you know which fields cause them difficulties? This is a guide to field-by-field form tracking using GTM. By tracking each element of the form separately, you will see how many people start filling out the form but then decide not to submit it. Once you understand where people drop off you will be able to identify any parts of the form that may need improving. The enquiry form on our website has four elements that I am going to track: the name, email and subject fields, and the button to submit the query. In summary, the set up will work like this: Create a trigger that will act as the firing rule for the tag Create a tag to track clicks on the field Repeat for each field So to set up the tracking of form fields and submits in GTM V2, follow these steps. Enable built in variables Firstly, you will need to enable built in variables. You will need Form ID variable and if similarly to our site you have the same enquiry form placed on several pages, then Page Path variable as well. These variables will allow you to track clicks on the form and on which pages the form was clicked on. The page path variable returns the URL part that comes after your main domain, eg /blog. Create the trigger For your trigger, you will need to find out the field ID you want to track. To find out the ID, if you are using Chrome browser, right-click on the field and select ‘Inspect Element’ It will look something like id=”name” so name here is the unique ID that you need to use with the trigger. If you do not have a unique ID associated with the field you want to track, ask your developers to add it in. This will make the tracking much easier. Now in GTM, go to Triggers tab on the left and click 'New'. You are creating a 'click' trigger, which you want to fire on 'all elements'. Save the trigger. Create the tag Go to Tags tab and click 'New'. Select Google Analytics and tag type 'Universal Analytics'. I send the following event tracking parameters to GA: Category: Enquiry form Action: Click on name Label: {{Page Path}} Now select 'Click' to select the trigger ‘Click on name’ as your firing rule. If there are any pages where you don’t want this tracked, then you will need to create a separate blocking trigger. Here is an example of a trigger for a contact us page that I want to exclude from tracking here. You can create your blocking trigger in a pop up window without leaving the tag. Repeat Follow the steps above to create the trigger and tag for each following field, and amend form ID’s and event field values for each. Test your tags in GTM debug mode and GA real time to make sure the details sent through are what you want. Once tested, publish your container and if you need any further help with any of the above, leave a comment below.   Further reading: How to track file downloads in Google Tag Manager V2 Tracking registered users with Google Analytics and GTM V2

2015-07-17

How to track file downloads in Google Tag Manager V2

Setting up tracking of file downloads in GTM V2 is much easier thanks to the new configuration wizard. It is more intuitive and takes you through the set up step-by-step. Let’s have a look at the basic configuration for sending tracking of file downloads from Google Tag Manager to Google Analytics as events. To set up this events tag you need to firstly create a trigger. Create a trigger This trigger will recognise every time someone clicks to download the file you want to track. In the given example I am using a simple regular expression to capture a number of file types I want to track -.(zip|exe|pdf|doc*|xls*|ppt*|mp3)$ Here the * means it will capture any repetitions of the file types it is next to, ie it will include file types doc and docx for Word documents, xls and xlsx for Excel spreadsheets, ppt and pptx for PowerPoint presentations. Save the trigger and create a new tag. Create a new tag Give your tag a meaningful name so you can easily recognise what the tag is for. We have previously created a variable (formerly known as macro) that stores our GA tracking code, which I use in the configuration settings. This way I do not have to re-enter the GA property ID every time I need it. This variable does all the work. Select your track type as 'Event' and insert your tracking parameters. Here I use the following but modify the fields based on what works for your business: Category is Download Action is Click Label is {{element url} Element url in the label field will store the URL of the file that was downloaded. Advanced tracking For advanced tracking, you can create a custom javascript variable with a code that will strip out the title of the downloaded file and store it in your GA. Have a look at Simo's example of returning file name. Set your tag to fire Last step is to add a firing rule, ie select a trigger that will fire your tag. Select the previously created trigger 'Click to Download' and you're all set. Test For extra care, test the tag both in GTM debug mode and GA real time. Publish Now publish the container with your newly created tag. If you need any further help, do leave a comment below.   Further reading: Tracking registered users with Google Analytics and GTM V2 Tracking web forms in Google Tag Manager V2

2015-06-04

How to audit your Web Analytics Ecommerce tracking

Most companies will see a discrepancy between the transaction volumes recorded via web analytics and those recorded via internal sales or financial database. This article focuses on how to find and reduce that discrepancy, to give greater credibility to your web analytics data. Following on from our article on common Google Analytics setup problems, we are often asked why Google Analytics ecommerce tracking is not a 100% match with other records, and what is an acceptable level of difference. Inspired by a talk from Richard Pickett at Ensighten, here is a checklist to run through to reduce the sources of mismatch. The focus here is Google Analytics Ecommerce tracking, but it could apply to other systems. In summary, you wouldn’t ever expect there to be a 1:1 match, due to the different paths the two events take over the internet. The general consensus is that anything less than 4% of difference in transaction volumes is good, but could sometimes persist up to 10%. Factors that affect this target rate include how many users have got ad blockers or disable Google Analytics (popular in Germany, for example), what proportion are on mobile devices (which suffer from more network interruptions) and how the purchase thank you / confirmation page is built. So on to the list. 1. Are other Javascript errors on the page blocking the ecommerce event in certain situations? The most common reason for the tracking script not executing in the browser is that another bug on your page has blocked it (see GDS research). The bug may only be affecting certain older browsers (like Internet Explorer 7), and have missed your own QA process, so the best approach is to use Google Tag Manager to listen for any Javascript error events on the confirmation page and send these to Google Analytics as custom events. That way your users do the testing for you, and you can drill into exactly which browsers and versions the bugs are affecting. 2. Is the tracking code as far up the page as it could be? If the user drops their internet connection before the whole page loads then the ecommerce event data won’t get a chance to fire. The best approach is to load the script at the bottom of the <head> element or top of the <body>.  The Google Analytics script itself won't block the page load, and arguably in this one purchase confirmation page, the tracking is more important than the user experience. 3. Is the tracking code firing before all the page data has loaded? The inverse of the previous problem: you may need to delay firing the tracking code until the data is ready. This is particularly an issue if your ecommerce transaction data is ‘scraped’ from the HTML elements via Google Tag Manager. If the page elements in question have not loaded before the ecommerce tracking script runs, then the product names, SKUs and prices will be empty – or returning an error. 4. Is the problem only your ecommerce tracking script or just page tracking is general? It could be that the way you are sending the transaction data (e.g. product name, price, quantity) is the problem, or that the page tracking overall is failing in some cases. You can pinpoint where the problem lies by comparing the pageviews of the confirmation page, with the number of ecommerce events tracked. Caveat: on many sites, there’s another route to seeing the purchase confirmation page, which doesn’t involve purchasing (for example as a receipt of a historic purchase). In that case, you may need to capture a unique purchase event, which only fires when a new purchase is confirmed – but without any information on the transaction or products. 5. Are events from your test site excluded? Most companies will have a development, staging or user acceptance testing server to where the website is tested, and test users can purchase.  Are you blocking the tracking from these test sites? Some possible ways to block the test site(s) would be: Set up sub-domain specific blocking rules in Google Tag Manager (or better) Divert the tracking from your test subdomains to a test Google Analytics account, using a lookup macro/variable Set up filters in the Google Analytics view to exclude 6. Is your tag set with a high priority? Tag manager only. If you use Google Tag Manager and have multiple tags firing on the tracking page it’s possible that other tags are blocking your ecommerce data tag from firing. Under ‘Advanced settings’ in the tag editor, you can set a higher priority number for tag firing; I assume the ecommerce data to Google Analytics is always the first priority. 7. Are any strings in the product name properly escaped? A common problem is apostrophes: if your product name contains a quote mark character, then it will break the following Javascript. See Pete’s bunnies – the strings in yellow are valid, and everything after the stray apostrophe will be misinterpreted. The solution is to run a script across any text field to either strip out the quotation marks or replace any quotes with their HTML equivalent (eg &quot;). 8. Are your quantities all integers? One of our clients was selling time slots, and so had the ‘quantity’ of the ecommerce tracking data equivalent to a number of hours. Timeslots sold in half-hours (e.g. 1.5 hours) were not tracking… because Google Analytics only recognises a quantity which is a whole number, so sending ‘1.05’ will not be recognised as 1. 9. Are any possible ‘undefined’ values handled? It may be that the data on your products is incomplete, and some products that people buy do not have a name, price or SKU. The safest approach is to have some fall-back values in your Javascript tracking code to look for undefined or non-text variables and post a default value to Google Analytics. E.g. If ‘product name’ is undefined then post ‘No product name’, or for price, the default should be ‘0.00’. These will then clearly show up in your Ecommerce Product performance reports and the data can be cleaned up. 10. Are users reloading the page and firing duplicate tracking events? Check whether this is a problem for your site by using our duplicate transactions custom report to see multiple events with the same transaction ID. A solution is to set a ‘has tracked’ cookie after the ecommerce tracking has been sent the first time, and then check whether the cookie is set before sending again. 11. Are users going back to the page and firing the tracking at a later date? The sessions column in the transactionID report in step 9 should give you an idea of whether the problem is repeat page loads in one session, or users revisiting the page in another session. If you see duplicate transaction IDs appearing in other sessions there are a couple of possibilities to investigate: Could users be seeing the page again by clicking on a link to an email, or from a list of historic orders? Are there any back-end admin pages that might link to the confirmation page as a receipt? In both cases, the solution is to have a different URL for the receipt that the one where the ecommerce tracking is fired. If there are any other troubleshooting steps you have found helpful, please let us know in the comments or get in touch!  

2015-03-17

6 helpful Google Analytics guides

I've been improving my knowledge of Google Analytics this month but found that documentation provided by Google and other heavy research can be difficult to absorb. So here are 6 guides and tools that I found useful in the last month. How to set up campaign tracking Expertise level: Newbie Social media analytics: How to track your marketing campaigns by Cory Rosenfield. When you run an ad, email or social promotion, you want to see which channel is most effective in acquiring visitors. By gathering this information through tracking your campaigns you will be able to focus on winning strategies and make adjustments to less performing ones. Cory’s how to guide takes you through the basics of how to set up campaign tracking with relevant explanations and practical examples. It’s as easy as it gets. What metadata needs fixing Expertise level: Beginner Introducing the Meta and Rich Snippet Tester by Bill Sebald. This tester from RankTank compares your site’s meta and rich snippet data to what you have in your site’s code. You will be able to see mismatches between how you have set your titles and descriptions against what is actually displayed in search results. Want to make sure rich snippets are working correctly or Google doesn’t replace missing meta tags with something unsuitable? Then this tool is for you. How to do keyword research effectively Expertise level: Intermediate Keyword research in 90 minutes by Jeremy Gottlieb. Keyword research for improved content targeting can take a lot of time but it doesn’t have to. Jeremy’s plan splits it into a 4-stage process, full of handy tips on how to spend your time effectively. Especially useful for when planning topics for your blog posts and finding words that are most relevant to include in your product descriptions. Setting up alerts for site errors Expertise level: Intermediate Google Analytics custom alerts which you must always use by Himanshu Sharma. How can you find errors and problems on your website with minimum manual labour? Set up custom alerts in your Google Analytics account with Himanshu's guide. You can create notifications for tracking and shopping cart issues, and any unusual changes in your bounce rate and traffic. How to improve multiscreen experience Expertise level: Advanced Enabling multiscreen tracking with Google Analytics by James Rosewell. This step by step guide by James shows how to get better data on the use of your site across various mobile devices. You will be able to make informed decisions on optimising your site whilst taking into consideration screen sizes and layouts. This means improved experience for customers on bigger smartphones and smaller tablets. Source: Infinium.co What were the different variables again? Expertise level: Advanced Variable guide for Google Tag Manager by Simo Ahava. Variables in Google Tag Manager can be powerful, once you get to grips with them. Simo's comprehensive guide is a useful reference that covers everything you need to know from technical details to set ups and debugging. Source: SimoAhava.com Need some help with Google Analytics? Get in touch with our experts!

2015-01-30

Complete picture of your ecommerce business

From marketing channels to buying behaviour, Littledata is the ultimate Google Analytics toolbox.

Get started