Google Analytics Code into VB.Net String

Please put this Google Analytics script into a VB.Net string. Like this:
  Dim strScript As String = _
                "<script src='http://www.google-analytics.com/urchin.js' type='text/javascript'> </script> " & _
                    "<script type='text/javascript'>_uacct = 'UA-xxxxxxx-1';urchinTracker();</script>"



<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">
try {
var pageTracker = _gat._getTracker("UA-xxxxxxx-1");
pageTracker._trackPageview();
} catch(err) {}</script>

Thank you!
LVL 1
ndonhauserAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
CodeCruiserConnect With a Mentor Commented:
Are you struggling with " ?

Try this

Dim strScript As String = "<script type=" & chr(34) & "text/javascript" & chr(34) & ">var gaJsHost = ((" & chr(34) & "https:" & chr(34) & "== document.location.protocol) ? " & chr(34) & "https://ssl." & chr(34) & " : " & chr(34) & "http://www." & chr(34) & ");document.write(unescape(" & chr(34) & "%3Cscript src='" & chr(34) & " + gaJsHost + " & chr(34) & "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E & chr(34) & ""));</script><script type=" & chr(34) & "text/javascript" & chr(34) & ">try {var pageTracker = _gat._getTracker(" & chr(34) & "UA-xxxxxxx-1" & chr(34) & ");pageTracker._trackPageview();} catch(err) {}</script>"
0
 
ndonhauserAuthor Commented:
Thank you!

            Dim strScript As String = String.Format( _
                    "<script type={0}text/javascript{0}>var gaJsHost = (({0}https:{0}== document.location.protocol) ? " & _
                    "{0}https://ssl.{0} : {0}http://www.{0});document.write(unescape({0}%3Cscript src='{0} + gaJsHost + " & _
                    "{0}google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E & chr(34) & ""));" & _
                    "</script><script type={0}text/javascript{0}>try {{var pageTracker = _gat._getTracker({0}{1}{0});" & _
                    "pageTracker._trackPageview();}} catch(err) {{}}</script>", Chr(34), strGoogleCode)
0
 
ndonhauserAuthor Commented:
Thank you
0
 
CodeCruiserCommented:
Glad to help :-)
0
All Courses

From novice to tech pro — start learning today.