eniva
Jul 7th 2008, 5:32 pm
Ok as most of you new google analytics now has the javascript function which is supposed to be better than the legacy.
Here is my question.
Can I call this externally with only one call?
For Example?
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxxx-xx");
pageTracker._initData();
pageTracker._trackPageview();
</script>
That is what google analytics gives you .. now i want to call this externally such as putting that in its own file.js and calling it with the code <script type="text/javascript" src="file.js"></script>
Now I know when i make the file.js I need to remove the <script type="text/javascript"> and </script> part ..
BUT
When I leave both the
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
var pageTracker = _gat._getTracker("UA-xxxxxxx-xx");
pageTracker._initData();
pageTracker._trackPageview();
in the FILE.js it does not work .. I have to put them in separate .js files and call them as
<script type="text/javascript" src="file.js"></script>
<script type="text/javascript" src="file1.js"></script>
Does anyone know why this is or how to fix this to only call it from one file?
Please let me know, thanks in advance!
Here is my question.
Can I call this externally with only one call?
For Example?
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxxx-xx");
pageTracker._initData();
pageTracker._trackPageview();
</script>
That is what google analytics gives you .. now i want to call this externally such as putting that in its own file.js and calling it with the code <script type="text/javascript" src="file.js"></script>
Now I know when i make the file.js I need to remove the <script type="text/javascript"> and </script> part ..
BUT
When I leave both the
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
var pageTracker = _gat._getTracker("UA-xxxxxxx-xx");
pageTracker._initData();
pageTracker._trackPageview();
in the FILE.js it does not work .. I have to put them in separate .js files and call them as
<script type="text/javascript" src="file.js"></script>
<script type="text/javascript" src="file1.js"></script>
Does anyone know why this is or how to fix this to only call it from one file?
Please let me know, thanks in advance!