Synchronous vs. Asynchronous Tags
For Piwik PRO Marketing Suite we offer two options for tracking code implementation – by asynchronous or synchronous loading of tags. But does these two tracking methods work and how are they different from each other?
For tags that are set to load in a synchronous manner, when a page loads a synchronous tag, it needs to wait for the tag content to load before moving on to the next content.
The page starts by loading the first tag. After the tag has been completely loaded, the page moves on the second tag. The process is then repeated for the remaining tags.
Example: If we have 4 tags on our website, then assuming each tag takes half a second to load, we’re looking at a total load time of 2 seconds to load all 4 tags.
Synchronous tags fire and load first – even before the page loads. The content of a page won’t appear until the tag fires. It’s a good practice to use synchronous tags for A/B tests.
With asynchronous tracking, the browser can load the different tags simultaneously. Contrary to synchronous tracking, it no longer has to wait for a certain tag to load completely before moving on to the next or the rest of the page content. It’s a good practice to use asynchronous tags for tracking tags.
Example: Using our example of the website with 4 tags, in case of asynchronous tags the browser starts downloading the 4 tags in parallel, completing the process much quicker.
Asynchronous tracking has many benefits. One of many is improved site performance (see example above). In addition to that, since tags are loading simultaneously with rest of content, they can be placed on top of the page, which improves the accuracy of data being collected.