Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a link on my site. That links goes to another URL on my site. The code on the server sees that resource being requested and redirects the browser to another website. Will Google Analytics be able to know that the user requested the URL from my server and was redirected?

Specifically, I set up a /buy link on my watchmecode.net site to try and track who is clicking the "Buy & Download" button. This link/button hits my server, and my server immediately does a redirect to the PayPal processing so the user can buy the screencast.

Is Google Analytics going to know that the user hit the /buy URL on my site, and track that for me? If not, what can I do to make that happen?

share|improve this question
up vote 6 down vote accepted

Short answer: no.

Google Analytics will only track a page view if the page loads and _trackPageview is called. You could call _trackPageview in a "Buy" click handler, but if you're going to do that I'd just fire an event instead.

share|improve this answer
can you expand on "fire an event" in terms of Google Analytics? – Derick Bailey Oct 31 '11 at 2:01
_gaq.push('_trackEvent', ...): code.google.com/apis/analytics/docs/tracking/… – dahlbyk Oct 31 '11 at 2:49
Thanks Keith! that seems to be what I need – Derick Bailey Oct 31 '11 at 3:25

Since you are redirecting server side this seems like it would be a good fit for their ECommerce API to post the transaction items client side before the redirect or when the user is redirected back to your site.

Also when the user does come back from your payment gateway you'll see refer to that page.

share|improve this answer

It has been a while since I looked into Google Analytics but can't you simply call urchinTracker on the onclick event?

Adding the following to your href may work for you.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.