How to link Google Analytics to your RSS feed so that you can track how many people visited the feed in ASP.NET
I spent a few days puzzling over this without luck then it hit me!
Just create a dummy page which has the Google Analytics JS embedded in it, in the OnInit of your RSS feed, use the System.Net.WebClient to load the dummy ASPX page dynamically:
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
try
{
using (WebClient objWebClient = new WebClient())
{
objWebClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
Stream data = objWebClient.OpenRead(BASE_URL + "DummyPage.aspx");
}
}
catch { }
}
Just create a dummy page which has the Google Analytics JS embedded in it, in the OnInit of your RSS feed, use the System.Net.WebClient to load the dummy ASPX page dynamically:
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
try
{
using (WebClient objWebClient = new WebClient())
{
objWebClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
Stream data = objWebClient.OpenRead(BASE_URL + "DummyPage.aspx");
}
}
catch { }
}
Comments
Post a Comment