Title: How do i insert a script
Last modified: August 23, 2023

---

# How do i insert a script

 *  Resolved [andersjytzler](https://wordpress.org/support/users/andersjytzler/)
 * (@andersjytzler)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/how-do-i-insert-a-script/)
 * Hey guys. I am helping a company with their WordPress website which is using 
   AMP.
   They want me to add a script to the website, and i have tried adding it 
   through functions.php, header.php and footer.php, but it doesn’t load on the 
   website. What am i doing wrong? Should i add it somewhere else?
 * I tried adding this in functions.php:
 *     ```wp-block-code
       function my_footerscripts(){
       ?>
       <script type="text/javascript">
           (function(e,t,o,n,p,r,i){e.visitorGlobalObjectAlias=n;e[e.visitorGlobalObjectAlias]=e[e.visitorGlobalObjectAlias]||function(){(e[e.visitorGlobalObjectAlias].q=e[e.visitorGlobalObjectAlias].q||[]).push(arguments)};e[e.visitorGlobalObjectAlias].l=(new Date).getTime();r=t.createElement("script");r.src=o;r.async=true;i=t.getElementsByTagName("script")[0];i.parentNode.insertBefore(r,i)})(window,document,"https://diffuser-cdn.app-us1.com/diffuser/diffuser.js","vgo");
           vgo('setAccount', 'XXXXXTHEIR_IDXXXXX');
           vgo('setTrackByDefault', true);
   
           vgo('process');
       </script>
       <?php
       };
       ```
   
 * And i also need to add this script:
 *     ```wp-block-code
       <!-- Byggfakta Analytics Pro -->
       <script async defer type="text/javascript" src="//stats.docu.info/docu-snippet.js" id="docu-snippet" data-site-id="7" data-domain-id="XXXTHEIR_IDXXX"></script>
       <!-- End Byggfakta Analytics Pro -->
       ```
   
 * UUID ampwp-2b9fe708-2a91-51df-a85a-a02b65260d14

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

 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/how-do-i-insert-a-script/#post-16995250)
 * Hello [@andersjytzler](https://wordpress.org/support/users/andersjytzler/)
 * Thank you for contacting us, [AMP does not allow custom javascript](https://amp.dev/documentation/guides-and-tutorials/learn/validation-workflow/validation_errors#custom-javascript-is-not-allowed)
   on AMP pages. so AMP plugin removes them to create a valid AMP page.
 * Instead, AMP uses Web components such as [amp-analytics](https://amp.dev/documentation/components/amp-analytics)
   which support [list of vendors](https://amp.dev/documentation/guides-and-tutorials/optimize-and-measure/configure-analytics/analytics-vendors#vendors)
 * You may also find [amp-pixel](https://amp.dev/documentation/components/amp-pixel)
   component helpful in tacking page views
 * AMP also allows custom javascript using [amp-script](https://amp.dev/documentation/guides-and-tutorials/develop/custom-javascript)
   tags but it runs on web worker and may not work for analytics tracking.
 * I am not sure if your vendor provides support for AMP, in that case, you can 
   contact them and ask to provide support for the same.
 * We will recommend contacting [AMP upstream](https://amp.dev/support/) (Web Component
   framework) for better guidance.
 * We hope this is helpful!
 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/how-do-i-insert-a-script/#post-17023544)
 * [@andersjytzler](https://wordpress.org/support/users/andersjytzler/) As we didn’t
   receive a response I’ll mark this as resolved. Feel free to open a [new support topic](https://wordpress.org/support/plugin/amp/#new-post)
   if you require any further assistance.
 *  Thread Starter [andersjytzler](https://wordpress.org/support/users/andersjytzler/)
 * (@andersjytzler)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/how-do-i-insert-a-script/#post-17023788)
 * I’m sorry [@milindmore22](https://wordpress.org/support/users/milindmore22/) 
   for not replying.
 * Your answer was very comprehensive and useful, thank you very much 😊🙏

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

The topic ‘How do i insert a script’ is closed to new replies.

 * ![](https://ps.w.org/amp/assets/icon.svg?rev=2527602)
 * [AMP](https://wordpress.org/plugins/amp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amp/)
 * [Active Topics](https://wordpress.org/support/plugin/amp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amp/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [andersjytzler](https://wordpress.org/support/users/andersjytzler/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/how-do-i-insert-a-script/#post-17023788)
 * Status: resolved