0

So I want to enable google analytics in a website application, so I have the code in the script tag itself. Is it better to have the code directly in the tag:

<script> 
    (functions(variables)google objects (morevariables), links);
</script>

Or is it better to have it in the form of:

<script src="link to where a js file with the exact same code as above is hosted"></script>

With three things in mind:

  1. Load Time (Normal page load as well as number of calls)
  2. Security (I doubt this is an issue, as people will have easy access to that code either ways, and I don't think its particularly confidential)
  3. google analytics should obviously catch everything properly.

1 Answer 1

1

In my experience y prefer to have the script in a separate file in order to reuse it in all my views. But I don´t think it makes any difference.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.