David Vallejo - Web Analyst

Yet another way/try to stop referrals/events spam on Google Analytics

The spam referrals problem in Google Analytics is turning into the new "not provided". Almost everyone I follow has posted/retweeted/said something about it in the past month. I didn't want to miss this oportunity to bring back some of the scripts I did in the past year for myself and share it with everyone. So in this post I'm going to try to address the Spam problem from another perspective that is not based on using referrals lists…


Handy dataLayer debugging tool for Chrome

One of those posts that were laying around on my drafts and that I've decided to publish. I know there're out there some good and well stablished tools that helps you to debug your Google Tag Manager implementation like the dataSlayer extension. But in the previous months I've been using a little JavaScript snippet that allows me to view in easy way the pushes that are being sent to Google Analytics in real-time in a nice way: This is how the debugging…


How to track an intranet or an hybrid app

As we all know (do we?) Google Analytics uses cookies in order to work. This is, if for some reason the cookie can't be set it won't give any error but hits won't be fired at all. A cookie is usually set for a FQHN (Fully Qualified Host Name). So if for example we're going to track our intranet and we access it using an URL like : http://intranet/ Google Analytics is likely not going to work (it will depend on the browser that is accessing the page.…


Learn how does Universal Analytics Cross Domain work

Univeral Analytics tracking is based on cookies and on a randomly generated clientId. Yep, that's it. Each time you visit a site using Google Analytics for the first time a new cookie is set in your browser with a randomly generated hash (clientId), that will be used by Google Analytics servers to identificate you in the subsecuent visits. Let's see how the cookie looks: Any of those values can be modified using the JavaScript API, and they need…


How does the Universal Analytics snippet work

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-123123123', 'auto'); ga('send', 'pageview'); The first thing that may attract your attention is the function parameters,…


Pushing data to the right Google Tag Manager dataLayer namespace

It may happen that the site we're tracking is using a custom dataLayer name, or that it's using more than one Google Tag Manager accounts at the same time and therefore (it should) using 2 different dataLayer namespaces.  Most of people just push the info to window.dataLayer variable, but it could be window.myOwnDataLayerNS . So we'd need to adapt our dataLayer pushes to that variable name. So we're going to setup a Macro that is going to take…


Blocking your tags firing from your own IPs with Google Tag Manager

The subject about how to exclude your own visits from GA has been commented before loads of times, most of time filters are used to keep out our own visits from Google Analytics , but some other tools may not have the possibility to filter out our own visits. This is why we're going to use Google Tag Manager to block all our tracking pixels, conversions pixels, custom tags, or whatever tag type we want. We're going to lay on a Lookup Table type macro…


Tracking the browser orientation status and changes

Last day we were talking about how to measure if our site was showing a responsive layout to our users, and today we're going to expand that tracking post with orientation tracking for our sites. We could use the Media Queries to match the orientation, but as this is not much standard we're going to use the window.orientation value and the viewPort Width and Height values to guess the current page orientation and pass that info to Google Analytics and…


Tracking a responsive site and the media queries changes

Every day more sites choose to use a responsive designs for their new sites, making it somekind difficult to track what version of our page is being showed to the user (as all we may now, browser detection is not perfect at all, most of them are based on the User Agent that can be easily faked). This post will try to show you the different ways to track if user's are viewing a responsive layout or not, and using the Google Analytics Event Tracking…


Tracking fragments based navigation websites with GTM the right way

We're going to learn how to track those websites where the navigation is based on Ajax, ie: no pages reloads with Google Tag Manager.  As you may know a full page reload is needed in order to have Google Analytics tracking your pageviews, but those sites like the ones based on AngularJS are not reloading the page just the current page content, so this new pages won't be tracked by our Analytics tools, or even catched by our conversion pixels.…