The Visiopt script should load before GTM in the header. Earlier is better, and here's why.
Visiopt has to identify the visitor, assign the variation, and apply the experience as early as possible in the page load.
Any delay means a window where the wrong version has the possibility of creating delays that you don't want.
GTM is where things get unpredictable.
Containers can delay, sequence, or conditionally fire scripts depending on how they're configured.
When Visiopt loads through GTM or after it, you've handed control of timing over to the container.
Putting Visiopt directly before GTM in the header gives the cleanest and fastest execution path.
Preferred script order in the header
Visiopt has to identify the visitor, assign the variation, and apply the experience as early as possible in the page load.
Any delay means a window where the wrong version has the possibility of creating delays that you don't want.
GTM is where things get unpredictable.
Containers can delay, sequence, or conditionally fire scripts depending on how they're configured.
When Visiopt loads through GTM or after it, you've handed control of timing over to the container.
Putting Visiopt directly before GTM in the header gives the cleanest and fastest execution path.
Preferred script order in the header
- Visiopt script
- GTM script
- Other tracking and marketing scripts (Meta Pixel, Google Ads, etc.)
What if GTM is already loading first?
It's not a dealbreaker. Tests will still run. But best practice is Visiopt first... and if you're setting up a new install or doing a cleanup pass on the header, this is the order to use.
That's just the reality of how page load timing works. The tools that need to fire earliest should load earliest.
Comments
0 comments
Please sign in to leave a comment.