KaranGupta
asked on
Google Analytics in asp.net
Hi
I want to impement google analytics in my asp.net application.
So I referred this tutorial
http://www.aspcode.net/The-Google-Analytics-ASPNET-webcontrol.aspx
Then I have created a custom control and add following code in it.(please see the code section)
Then I have referred the dll in my project and added the following code in my .aspx file
<%@ Register TagPrefix="analytics" TagName="GoogleAnalytics" Namespace="GoogleAnalytics Ctrl" Assembly="GoogleAnalyticsC trl"%>
<analytics:GoogleAnalytics id="google1" runat="server" uacct="UA-zzzzz-x" DebugMode="false"></analyt ics:Google Analytics>
But I am getting this error
1. The directive is missing a 'src' attribute.
2.Unknown server tag 'analytics:GoogleAnalytics '.
Is there anything wrong with the code.
Kindly advice
Regards
Karan
I want to impement google analytics in my asp.net application.
So I referred this tutorial
http://www.aspcode.net/The-Google-Analytics-ASPNET-webcontrol.aspx
Then I have created a custom control and add following code in it.(please see the code section)
Then I have referred the dll in my project and added the following code in my .aspx file
<%@ Register TagPrefix="analytics" TagName="GoogleAnalytics" Namespace="GoogleAnalytics
<analytics:GoogleAnalytics
But I am getting this error
1. The directive is missing a 'src' attribute.
2.Unknown server tag 'analytics:GoogleAnalytics
Is there anything wrong with the code.
Kindly advice
Regards
Karan
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace GoogleAnalyticsCtrl
<DefaultProperty("uacct")> _
<ToolboxData("<{0}:GoogleAnalytics runat=server></{0}:GoogleAnalytics>")> _
Public Class GoogleAnalytics
Inherits WebControl
Protected Overrides Sub OnInit(ByVal e As EventArgs)
Me.EnableViewState = False
MyBase.OnInit(e)
End Sub
Private m_uacct As String = "UA-"
<Bindable(True)> _
<Category("Appearance")> _
<DefaultValue("")> _
<Localizable(True)> _
Public Property uacct() As String
Get
Return m_uacct
End Get
Set(ByVal value As String)
m_uacct = value
End Set
End Property
Private m_DebugMode As [Boolean] = False
<Bindable(True)> _
<Category("Appearance")> _
<DefaultValue("true")> _
<Localizable(True)> _
Public Property DebugMode() As [Boolean]
Get
Return m_DebugMode
End Get
Set(ByVal value As [Boolean])
m_DebugMode = value
End Set
End Property
Protected Overrides Sub RenderContents(ByVal output As HtmlTextWriter)
If DebugMode Then
Return
End If
Dim sScript As String = "<script src=""http://www.google-analytics.com/urchin.js"" type=""text/javascript"">" & vbCr & vbLf & "</script>" & vbCr & vbLf & "<script type=""text/javascript"">" & vbCr & vbLf & "_uacct = """ & uacct & """;" & vbCr & vbLf & "urchinTracker();" & vbCr & vbLf & "</script>"
output.Write(sScript)
End Sub
End Class
End Namespace
ASKER
Hi
Is there any function where I should put this code.
Secondly after I add the code I want to show the information on my web page. How can I do that
Is there any function where I should put this code.
Secondly after I add the code I want to show the information on my web page. How can I do that
Hey,
Analytics is a simple javascript client side code. So just copy the js code from your analytics and paste it before the page </body>
and
Secondly after I add the code I want to show the information on my web page. How can I do that
How do you mean ?
Analytics is a simple javascript client side code. So just copy the js code from your analytics and paste it before the page </body>
and
Secondly after I add the code I want to show the information on my web page. How can I do that
How do you mean ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
I have pasted the code before the body tag.
What is this code meant for.
Can this code give data about no of visitors etc.
I have pasted the code before the body tag.
What is this code meant for.
Can this code give data about no of visitors etc.
Yes google analytics tracks all your visitors which you view all the visitor info in the google analytic pagecontrol panel. page
'analytics:GoogleAnalytics
The dll is not referenced or not being called. Try removing the reference and adding again.
Btw why do you need all this why not just add the javascript to the master page. I first thought you have some custom requirement
But
Dim sScript As String = "<script src=""http://www.google-analytics.com/urchin.js"" type=""text/javascript"">"
So why not just this in the master page.