Google Universal Analytics

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/70702?pagenum=1
05 November 2025, 10:42

Topic


Webbo
Google Universal Analytics
01 February 2014, 18:19


Does anyone fancy rewriting the previous Google Analytics code mod to use the new Google Analytics code ?
The previous code was:

Code:

  Response.write    "<script type=""text/javascript"">" & vbNewLine & _
"var gaJsHost = ((""https:"" == document.location.protocol) ? ""https://ssl."" : ""http://www."");" & vbNewLine & _
"document.write(unescape(""%3Cscript src='"" + gaJsHost + ""google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E""));" & vbNewLine & _
"</script>" & vbNewLine & _
"<script type=""text/javascript"">" & vbNewLine & _
"var pageTracker = _gat._getTracker(""UA-usernumber"");" & vbNewLine & _
"pageTracker._initData();" & vbNewLine & _
"pageTracker._trackPageview();" & vbNewLine & _
"</script>" & vbNewLine


The new tracking code for Google Universal Analytics is...
Code:

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-usenumber', 'site name');
ga('send', 'pageview');

</script>

It needs writing into vbscript smile

 

Replies ...


Carefree
01 February 2014, 19:19


Not really, you can escape into HTML and leave it alone.
<%
' vbscript here
%>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-usenumber', 'site name');
ga('send', 'pageview');

</script>
<%
' back to vbscript here....
Webbo
03 February 2014, 02:16


I never thought of that
Worked but didn't need the <% at the beginning
© 2000-2021 Snitz™ Communications