Take your business to next level
Become part of our growing family of +600,000 users and get the tools you need to make smart choices for your website. Simple, powerful insights are just a click away.
Available since version 14.12.3
The wp_statistics_tracker_loading_strategy
filter allows you to customize the loading strategy of the tracker.js script.
WP Statistics uses tracker.js to track user activity, and it is typically added to your website’s footer. The script doesn’t use a specific loading strategy (e.g., defer
or async
) by default. This is because placing it in the footer ensures it doesn’t block the page’s content from loading.
However, some page insight tools might suggest that you need to have for example “defer” loading strategy.
You can use the wp_statistics_tracker_loading_strategy
hook to add your desired strategy to the script.
Add the following hooks to the functions.php
file of your active theme.
function tracker_loading_strategy() {
return 'defer'; // You can use 'defer' or 'async'
}
add_filter("wp_statistics_tracker_loading_strategy", 'tracker_loading_strategy');
Become part of our growing family of +600,000 users and get the tools you need to make smart choices for your website. Simple, powerful insights are just a click away.