Recently, a client asked us to remove all marketing tags for the sake of decreasing page load times. You can imagine that removing all marketing tags can hamper an online marketing strategy severely. Therefore, we went and looked for a solution that would still allow us to use marketing tags, but to be less of a burden on page load times. A possible solution is using session storage.
Expounding the issue
Multiple marketing tags were being fired on all pages – endeavouring to build audiences that contain all website visitors. However – these tags would fire on every single pageview for every user, rather than solely firing on the first hit. The krux is that some tags are to be fired after a user gives consent. The giving of consent can happen at a second page(view), therefore, a simple ‘fire only on first pageview’ rule would not suffice. Session storage allows us to fire tags only on the first page of visit – or the first page of visit after giving consent.
Note that some marketing tags, e.g. a Facebook WCA pixel – should still fire on all pages as this pixel uses URL data. For platforms such as AppNexus, Ligatus (LiquidM) and other platforms where pixels do not use URL data, firing it only once does the trick.
Introducing session storage
To use the session storage, first, we ensure that we set the session storage after the pixel is loaded for the first time. This can be achieved by adding the following line of code to the function that triggers your marketing tags (after calling for the tags).
sessionStorage.setItem('segment_session_storage_test', 'true')
Now – depending on your tag manager setup – you can add this to an include rule:
sessionStorage.getItem('segment_session_storage_test') === null
Tags will then be triggered when the session storage value for our segment is null.
If you use for example Google Tag Manager, you can also use the session storage in a blocking rule. For example – setting a tag to fire on all pages but do not fire it when the session storage is set.
sessionStorage.getItem('segment_session_storage_test') === true
Especially for larger websites with several tags that are to be fired, this could significantly affect page load times.
Leave a Reply
You must be logged in to post a comment.