Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relative URL path for linkid.js

I am trying to host the JS files linkid.js and analytics.js locally in our dedicated CDN server. right now we are referencing to both files as follow:

(window,document,'script','//www.google-analytics.com/analytics.js','ga')

and

ga('require', 'linkid', 'linkid.js');

is it easy for me to change the URL reference for analytics.js but i am not sure if I can do that for linkid.js! Looked for documentation but couldn't find an answer if it accepts a relative URL or not. How to handle this situation

EDIT 1: The reason why i need to do that: enter image description here

like image 384
IndieTech Solutions Avatar asked Oct 20 '22 11:10

IndieTech Solutions


1 Answers

Due to security reason, the require command doesn't allow you to source random script tags; Only the official plugins and locally hosted.

You will have to add another tag to your page:

<script async src="https://mycnd.com/linkid.js"></script>

and then use:

ga('require', 'linkid', 'https://mycnd.com/linkid.js');

Setting the url in the 3rd param will trip the security settings and prevent it from loading. The plugin will get loaded once the tag loads.

Do you really need to host it on your own CDN? Mind sharing your reasons?

like image 165
David Pattison Avatar answered Oct 22 '22 23:10

David Pattison