Skip to main content

4 Google Analytics Goal Types That Are Critical To Your Business

Hacking URL Goals with Virtual Pageviews

In Google Analytics, we can force a pageview into the system whenever we want. With a small bit of JavaScript, Google Analytics will track anything as a pageview. We can even define exactly what the URL is.

Doing this with any link is super easy. Let’s say we want to track a link to another domain and the link is so important that we want to make it a goal. We could use events to track it but we’ve decided that we want to use the goal as part of a goal funnel. Since event goals don’t allow us to do this, how can we use virtual pageviews and a URL goal?

Here’s your normal link:

Click Here!

Now we have to decide how we want the URL to look in our reports. We can’t get it to display as because Google Analytics will think the URL is a part of our domain. Let’s build a URL that easily tells us that it’s a virtual pageview, what domain it’s pointing to, and what page on that domain our visitors are going to. Which gives us a URL like this:


Remember: Google Analytics drops your domain in your URLs. For this virtual pageview, Google Analytics thinks that actually exists on your domain. But we’ve tricked it.

The vpv stands for virtual pageview so we know this URL is fake, “othersite” tells us which external domain we linked to, and  “promotion” clarifies which page we’ve linked to specifically. You can name your virtual pageview URLs whatever you want. But take the time to name them in such a way that you can instantly figure out what they are 6 months from now.

Now let’s use our fake URL with an onclick event and modify the original hyperlink. We’ll end up with this:

Click Here!

This code tells Google Analytics to register a pageview at the URL we’ve specified every time the link is clicked.

Google Actually will start using the /vpv/othersite/promotion URL which we can now use as a URL destination goal. We can even use this virtual pageview in a goal funnel which we can’t do with event goals.

You can use the virtual pageview trick for external links, file downloads, or any other element on your site.