Hi there,
In your wp_enqueue_script hook, you just need to use a number for a priority that is lower than MonsterInsights’s number. So like add_action( ‘wp_enqueue_scripts’, ‘my_script_function’, 1);
-Chris
Wow! Thanks so much. It was actually the class-tracking-ga.php that was too high, but looking through your plugin I found where that was being loaded via add_action wp_head. So copied that structure and changed the 8 priority to a 7, and now I can stick stuff in above the GA script. AND I learned something super valuable! Thanks!
Well… I made a valiant effort, but the problem is still that the analytics code (not the enqueued monster.js script) is too high in order to use Google Experiments.
I need this order:
1. jQuery load
2. Google Exp Code
3. Analytics snippet
I was able to dequeue jQuery and then manually re-add jQuery in with my add_action function that injects just before your analytics snippet, but then Gravity forms dies (and maybe other things), supposedly because somewhere in the assembly of the wordpress template jQuery is needed before I dequeued it.
So what I need is to lowed the monster analytics snippet below where jquery is being loaded, and then I can hopefully enqueue a script in between. Is there a function I can add to pull that down after it’s been place but before the page is rendered?