Hi,
I need to put the script of my cookie banner at the top of the <head> section of my site. So it should be the very first.
I do it via Hook wp-head.
The problem is that the google analytics script is always on top.
<script type="text/javascript" async="" src="https://www.google-analytics.com/analytics.js"></script>
For analytics, I use Global Site Tag (gtag.js) tracking code. I put it in the Hook wp-head with a priority 15.
My cookie banner script I put in the Hook wp-head with a priority 1.
When I see html – Global Site Tag (gtag.js) tracking code
<script src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-1" type="text/javascript"></script>
is below my cookie banner script. So, it’s OK. But I don’t know how to move google analytics script.
So, how can I put my script at the top?
Thank you.