The FPID Cookie for Google Analytics in Server-Side Tagging

Last updated 27 April 2023 with details about preventing FPID access in cookieless scenarios. With Server-side tagging, the developer community has a chance to vastly improve the data collection capabilities of Google’s analytics platforms (Universal Analytics and App+Web). The ability to build our own templates is particularly potent with a Server container. However, it’s not as if Google themselves are just sitting idly by and seeing what the community can come up with. Read More…

#GTMTips: Build a Custom Universal Analytics Client for Server-Side Tagging

You can utilize Server-side tagging in Google Tag Manager to build your own custom Universal Analytics proxy. This proxy comes in the shape of a new Client custom template, which takes the incoming /collect requests and sends them to Google Analytics. While doing so, it also returns the _ga cookie in a Set-Cookie header, thus preventing Safari’s Intelligent Tracking Prevention from capping its expiration to just 7 days. You might also be interested in reading what Google’s own solution is for migrating from JavaScript cookies to those set in HTTP headers. Read More…

#GTMTips: Simple Way to Exclude Internal Visits From Google Analytics

With so many people working from home or remotely in these turbulent times, it’s time to revisit one of my oldest articles, and discuss the options you have for excluding or segmenting internal traffic in Google Analytics. The traditional method of IP address exclusion is not necessarily the best option anymore, unless all your employees use a specific VPN to connect to the site. In this article, we’ll go through some of the tools you have at your disposal. Read More…

Tracking Cross-Domain Iframes - Upgraded Solution

**Last updated 18 September 2020: Due to how most browsers now have third-party cookie protections in place, this solution will be very ineffective going forwards. You should instead take a look at a cookieless solution. Some years ago, I wrote a post on how to track cross-domain iframes when using Google Tag Manager and Google Analytics. That solution relied on hitCallback to decorate the iframe, and now that I look back on it, it has its shortcomings. Read More…

Add Client ID to Custom Dimension With Gtag.js

When Google released gtag.js, the new, global tracking library designed to (eventually) replace analytics.js, many Universal Analytics practitioners and users were confused (see e.g. Jeff’s great overview here). It seemed like gtag.js wasn’t really solving any immediate problem, since analytics.js had done a bang-up job with Universal Analytics tracking for all these years. However, gtag’s modus operandi is the ability to leverage the same semantic information (distributed across dataLayer!) across a number of Google products, starting with GA and AdWords. Read More…

Send Event and Custom Dimension if Google Optimize Experiment Is Running

I really like Google Optimize. It has a fairly intuitive UI, setting up experiments is easy, and there’s integrations for both Google Tag Manager and Google Analytics built into the system. It’s still a JavaScript-based, client-side A/B-testing tool, so problems with flicker and asynchronous loading are ever-present (though this is somewhat mitigated by the page-hiding snippet). One issue with the Google Analytics integration is the difficulty of creating segments for sessions where the users were actively participating in the experiment. Read More…

#GTMTips: Respect Opt-Out From Advertising and Analytics

With GDPR looming around the corner, it’s time to explore the options you have at your disposal for respecting the new, stricter regulations for tracking users and for collecting data about their visits to your website. UPDATE 20 June 2018: Google has released the allowAdFeatures field which renders the solution below redundant (at least for the displayFeaturesTask part of it). Please refer to this article for more details on how to conditionally block the advertising hit to DoubleClick. Read More…

Prevent Site Speed Sampling Rate From Skewing Custom Dimensions and Custom Metrics

Universal Analytics can collect Page Timing data from users that load your pages. This data is populated in to the Behavior -> Site Speed -> Page Timings report, and it’s a very useful feature for optimizing your website. However, there’s a murky underside to this generous feature. The way Page Timings collection works is that when Pageview hits are sent from the site, a sample of these (1% by default) are automatically followed by a timing hit which includes page performance data grabbed from the Navigation Timing API. Read More…

#GTMTips: Send Google Analytics Tag to Multiple Properties

Here we are again, revisiting an old theme. When using Google Tag Manager, we often want to send the contents of the same tag to multiple Universal Analytics properties. With on-page GA, this used to be quite simple, as all you had to do was create a new tracker and then just remember to run the ga('trackerName.send'...) commands to all the trackers (or you could use my duplicator plugin). With GTM, your options are more limited, since Google Tag Manager abstracts the tracker object, giving you far fewer tools to work with. Read More…

#GTMTips: Use CustomTask to Access Tracker Values in Google Tag Manager

One of the things I’ve recommended from the get-go is to always send the Client ID to Google Analytics with your users’ hits. This is very useful for adding a level of granularity to your tracking. At first, I recommended using an Event tag to do this. Then I modified my approach a little so that you could send it with your initial Page View (thus not inflating your hit counts). Read More…