I recently upgraded our DNN instance from 3.x to 4.8.2. We were already using Google Analytics for our DNN site, but after the upgrade, for some reason, the Google Analytics code was no longer appearing on the page when I did a view source in the browser. I have the code in the skin like so:
<script runat="server" language="vb">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sb As New System.Text.StringBuilder
sb.Append(Environment.NewLine & "<scr" & "ipt src=""https://ssl.google-analytics.com/urchin.js"" type=""text/javascript"">")
sb.Append(Environment.NewLine & "</scr" & "ipt>" & Environment.NewLine)
sb.Append("<scr" & "ipt type=""text/javascript"">" & Environment.NewLine)
sb.Append("_uacct = ""UA-XXXXX-X"";" & Environment.NewLine)
sb.Append("urchinTracker();" & Environment.NewLine)
sb.Append("</scr" & "ipt>" & Environment.NewLine)
Dim ph As System.Web.UI.WebControls.PlaceHolder
ph = Page.FindControl("phDNNHead")
If Not ph Is Nothing Then
ph.Controls.Add(New System.Web.UI.LiteralControl(sb.ToString))
End If
End Sub
</script>
When I'm viewing the skin.ascx file in Visual Studio, I see the code above, but when I do a view source in the browser, it's like the code was never added. It was working when I was running this same code in DNN 3.x. Is there some issues with DNN 4.x and injecting javascript into a skin file in the way that I am doing above? Has anyone else seen an issue like this? I tried adding this code at the beginning and end of the skin file, but neither case worked. I can't imagine that I'm the only one who has run into this problem. Any help would be greatly appreciated.