Title: Adding extra scripts after the initial script ends
Last modified: August 31, 2016

---

# Adding extra scripts after the initial script ends

 *  [joycegrace](https://wordpress.org/support/users/joycegrace/)
 * (@joycegrace)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/adding-extra-scripts-after-the-initial-script-ends/)
 * Hi there,
 * I need to add the autotrack.js script right after the Google Analytics by Yoast
   script tag ends.
 * Can you let me know if there are documented ways to do this? I have tried googling
   but so far can’t find anything. I could just be blind. Sorry.
 * For example like so:
    <script> window.ga=window.ga||function(){(ga.q=ga.q||[]).
   push(arguments)};ga.l=+new Date; ga(‘create’, ‘UA-XXXXX-Y’, ‘auto’); **ga(‘require’,‘
   autotrack’); –> I can put this in the Custom code area of this plugin using _gaTracker
   instead of ga ** ga(‘send’, ‘pageview’); </script> **<script async src=’[https://www.google-analytics.com/analytics.js’></script&gt](https://www.google-analytics.com/analytics.js’></script&gt);–
   > This is the part I’d like to load right in this spot instead of elsewhere on
   the page. Ideas?** <script async src=’path/to/autotrack.js’></script> ** –> ideas
   for this?**
 * Any help is much appreciated!
 * Here is a reference: [https://github.com/googleanalytics/autotrack](https://github.com/googleanalytics/autotrack)
 * [https://wordpress.org/plugins/google-analytics-for-wordpress/](https://wordpress.org/plugins/google-analytics-for-wordpress/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [joycegrace](https://wordpress.org/support/users/joycegrace/)
 * (@joycegrace)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/adding-extra-scripts-after-the-initial-script-ends/#post-7217470)
 * Hi this turned out to be unnecessary. Sorry for the trouble. I realized I was
   mis-reading instructions earlier, and kind of asking a dumb question.
 * For those who want to know, and are researching this:
 * Google Analytics scripts are designed to be able to load before or after the 
   main tracking script, so the autotrack.js can be loaded in the header, like any
   other script.
 * It has to be uploaded to your site though, and it needs to be set up in the custom
   code section of the Google Analytics by Yoast plugin. So go to Google Analytics
   > Settings > Advanced tab and in the custom code box you can enter this:
 * __gaTracker(‘require’, ‘autotrack’);
 * And then you can start using autotrack.
 * note: the format of “__gaTracker” is a Google Analytics by Yoast plugin thing–
   if you are using another plugin or another method of inserting your tracking 
   code, you may need to use just plain “ga” or something else specific to the plugin
   you’re using. Yoast or someone else may need to confirm this. Google Analytics
   pages and instructions will tell you to use “ga”.
 * So, then, after that is set up, for example you can add this to a submit button
   on a form:
 * data-event-category=”Booking form” data-event-action=”Submit” data-event-label
   =”home page booking form”
 * (all samples used above, but you always need to enter “data-event-category=”something””
   and so on)
 * This is way easier than setting up tracking without autotrack.js, which would
   look something like what this site will generate for you:
    [https://raventools.com/gaconfig/google-analytics-event-tracking/](https://raventools.com/gaconfig/google-analytics-event-tracking/)
 * That means with autotrack.js your HTML would look something like this:
 * <input type=”submit” id=”your-button-id” class=”your-button-class” value=”Submit”**
   data-event-category=”category-name” data-event-action=”Submit” data-event-label
   =”label-you-want-to-name-this”** onclick=”” />
 * I was able to use Fast Secure Contact Form as well by going to their Advanced
   tab on a form and entering these as submit button attributes. Just an extra tip.
   But you can do this on any event. Like a video play button, etc.
 * Oh and Autotrack.js can track your social shares, and other things. Pretty nifty.
   See links in my original post for more info.

Viewing 1 replies (of 1 total)

The topic ‘Adding extra scripts after the initial script ends’ 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/)

## Tags

 * [google analytics by yoast](https://wordpress.org/support/topic-tag/google-analytics-by-yoast/)

 * 1 reply
 * 1 participant
 * Last reply from: [joycegrace](https://wordpress.org/support/users/joycegrace/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/adding-extra-scripts-after-the-initial-script-ends/#post-7217470)
 * Status: not resolved