Tip of the Week: Asynchronous tracking code

Asynchronous tracking code for top Google rankings

To enable etracker Analytics to collect data, the etracker code first initiates the loading of another script. This process can be synchronous or asynchronous. In synchronous mode, the actual content of the page is only loaded after the etracker code has been executed. In asynchronous mode, on the other hand, scripts can be executed simultaneously. This means that tracking has no influence on the loading speed of the website content and other scripts. The result: top Core Web Vitals values and excellent Google rankings.

Whether the asynchronous code is integrated can be seen from the parameter marked in the following example:

The asynchronous code can be found in all etracker accounts under Account Info → Settings → Setup/Tracking Code.

If you have integrated the older synchronous tracking code, you can easily adapt it by replacing src=”//static.etracker.com/code/e.js” with src=”//code.etracker.com/code/e.js” and adding the async keyword. 

Caution: If you use asynchronous code retrieval and eCommerce events, timing problems may occur. This can result in the eCommerce events not being transmitted successfully. To ensure that the etracker code has already been loaded before the eCommerce events are sent, the eCommerce API call should be made in the following function:

<script>
function _etrackerOnReady() {
  etCommerce.sendEvent('viewProduct', { /* product /* } );
}
</script>

Or in this function if several events are to be sent at different points in the code:

<script>
var _etrackerOnReady = [];
_etrackerOnReady.push(function() {
  etCommerce.sendEvent('viewProduct', { /* product1 /* });
});
</script>
...
<script>
_etrackerOnReady.push(function() {
  etCommerce.sendEvent('viewProduct', { /* product2 /* });
});
</script>

For more information, see this blog article.

Scroll to Top