Don’t let OAuth fool your analytics

Many sites use social sign-up tools to make users’ registration seamless. But this turns into a headache for web analysts. Google Analytics relies on referrer value to identify traffic source and to distinguish between user sessions. If user reaches site from organic search results, the referrer includes search engine domain and page address so user can be tracked via Google Analytics as google/organic. If then user signs up with a social plug-in, she is automatically taken to a social platform authorization page to confirm sign-up and allow data access and then is sent back to site. At this moment Google Analytics sees the social platform page authorization page referrer so it start new session for this user and override original traffic source information. In Analytics reports any further actions of this user won’t be counted with google/organic source/medium. Google Analytics provides referral exclusions mechanism, that modifies this behavior and skips source/medium assignment and session overriding for traffic from domains in the list. However, referral exclusions are not applicable in case of social sign-up because it would break all the social traffic measurement. It caused many problems and no robust solutions has been proposed so far.

I’ve discovered that this issue can be solved using Google Tag Manager triggers and Universal Analytics Tag. The solution relies on a feature of Google analytics session assignment procedure. If the referrer value provided with the analytics hit data contains the same domain as site’s domain this hit is included in the same session as the previous one. And GTM allows to easily override referrer value with setting up a trigger that fires when referrer includes some specific value (e.g. www.facebook.com/v2.4/dialog/oauth ). This trigger should fire a modified Universal Analytics Tag with field referrer set to some site’s own domain:

GTM trigger configuration
Modified Tag configuration

I’ve tested this solution recently with two visits, one direct and one custom tagged source where test1.html was landing page and test2.html was visited from referred page. With modified tag I got two plain sessions with no breaks and referral source assignment:

Like what you read? Give Dmytro Bulakh a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.