0

I am creating a .NET page specifically for firing a Google Analytics event. The reason is that I want to be able to see how many people are clicking links I send out in emails. The best idea I had was to make a simple .NET page which fires an event then redirects to a document.

Problem is, it redirects just fine using: protected void Page_Load(object sender, EventArgs e) { Response.Redirect("...". true); }

But I can't get the event to fire. I tried using StringBuilder which is the way I am accustomed to adding script from code-behind. Any suggestions on a way to get the event to work, or even a better way to fire an event for email clicks to documents?

1 Answers1

0

The reason the Google analytics event is not happening is that Google Analytics is client-side script.

Client side script is delivered when the server sends the HTML and JavaScript (and other content to the browser.

By using Response.Redirect on the server, you are ensuring that the web server never sends that HTML and JavaScript out to the browser. Instead, the web server sends an http code (Http status-code 302) telling the web browser to go to the page you're redirecting to.

It you want to track the clicks you'd be better off just saving them in a database in the Page_Load event, rather than trying to use Google Analytics.

Community
  • 1
  • 1
David
  • 72,686
  • 18
  • 132
  • 173