The 0bserver
The 0bserver

Reputation: 986

Google Analytics script in script tag or link to script

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.

Upvotes: 0

Views: 90

Answers (1)

Gonzalo de la Torre
Gonzalo de la Torre

Reputation: 31

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.

Upvotes: 1

Related Questions