Title: Insert script above MonsterInsights analytics
Last modified: June 22, 2017

---

# Insert script above MonsterInsights analytics

 *  Resolved [ben8jam](https://wordpress.org/support/users/ben8jam/)
 * (@ben8jam)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/insert-script-above-monsterinsights-analytics/)
 * Hello. I need to insert a script above GA, however, the Monsterinsights GA code
   is so high up in the head I can’t use the normal enqueue line to put in my code.
   How can I inject code above your plugin? Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [chriscct7](https://wordpress.org/support/users/chriscct7/)
 * (@chriscct7)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/insert-script-above-monsterinsights-analytics/#post-9252568)
 * 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
 *  Thread Starter [ben8jam](https://wordpress.org/support/users/ben8jam/)
 * (@ben8jam)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/insert-script-above-monsterinsights-analytics/#post-9254382)
 * 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!
 *  Plugin Author [chriscct7](https://wordpress.org/support/users/chriscct7/)
 * (@chriscct7)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/insert-script-above-monsterinsights-analytics/#post-9255081)
 * Not a problem!
 *  Thread Starter [ben8jam](https://wordpress.org/support/users/ben8jam/)
 * (@ben8jam)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/insert-script-above-monsterinsights-analytics/#post-9264391)
 * 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?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Insert script above MonsterInsights analytics’ is closed to new replies.

 * ![](https://ps.w.org/google-analytics-for-wordpress/assets/icon.svg?rev=2976619)
 * [MonsterInsights - Google Analytics Dashboard for WordPress (Website Stats Made Easy)](https://wordpress.org/plugins/google-analytics-for-wordpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-analytics-for-wordpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-analytics-for-wordpress/)
 * [Active Topics](https://wordpress.org/support/plugin/google-analytics-for-wordpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-analytics-for-wordpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-analytics-for-wordpress/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [ben8jam](https://wordpress.org/support/users/ben8jam/)
 * Last activity: [8 years, 11 months ago](https://wordpress.org/support/topic/insert-script-above-monsterinsights-analytics/#post-9264391)
 * Status: resolved