Skip to content
Mike Gutzschhahn edited this page Jul 12, 2016 · 6 revisions

1st Load without cache 2nd load with deleted cookie

Assuming internal traffic has to access a specific login page a distinct resource or it’s connection information (either DNS or even SSL) should cached. By catching this resource and checking it's timing metrics through the HTML5 Resource Timing API it could be verified if a user has visited this site. Checking is limited by the caching settings.

Here is an example resource: https://www.facebook.com/rsrc.php/v2/yx/r/krVStNVwu9p.png

Features

Upcoming

  • Usage modes debug with console logs, verification with events and production with user ID
  • setting a user ID in GTM

Notes

  • A distinct resource must be know and set
  • This resource must have the timing-allow-origin response header set (https://www.w3.org/TR/resource-timing/#timing-allow-origin)
  • GTM firing rule required to check session cookie to prevent double checks
  • console logs are currently used for verification

Check if resource Timing API is available To prevent undesired JavaScript errors it must be verified if the Resource Timing API is available. In the Google Tag manager this could be archived with a custom JavaScript variable which contains the following code:

function checkResourceTiming() { try { if( !(/MSIE (\d.\d+);/.test(navigator.userAgent) || window.performance.getEntriesByType === undefined) ) { return true; } } catch(err) {} }

Plus a firing rule checking for a first party cookie to prevent multiple executions. Here is the firing rule: Event: Page view Trigger: Page view

Fire On 1st condition: "Set Session Cookie" equals undefined 2nd condition: "Feature check - Resource Timing API" equals true

Clone this wiki locally