This article will help you:
  • Track a visitor's pageviews (to measure the success of your variation)
  • Set up a pageview goal in Optimizely
  • Use regular expressions to match a custom range of pages

You can track the number of unique and total impressions on a specific page, or subset of pages, by adding a pageview goal to your experiment. 

Want to see pageview goals in action? Watch this short video.

 
 

Pageview goals in a nutshell

Use pageview goals to track unique / total impressions on pages or subsets of pages. For example, you create an experiment on your product category page. Add pageview goals to the product detail pages to measure whether visitors viewed more products as a result.

Key tips 

  • Add pageview goals using URL match types, the same concept used in Optimizely's URL targeting
  • Click the "+" button to add more than one URL to the same pageview goal

What to watch out for

Some common pageview goals you may set up are:

  • Tracking the number of unique impressions on a confirmation page.
  • Tracking each page in a checkout funnel to measure engagment or dropoff.
  • Tracking pages that contain certain content (such as video pages).
  • Tracking pages/visitor by setting a pageview goal with a substring match for the site's parent domain

Setting up a pageview goal

To create a pageview goal, follow the seven steps outlined below:

  1. In the Editor, click the Goals icon.

  2. Click Create a New Goal.


     
  3. Choose Pageviews from the What to Track dropdown menu.

  4. Give your goal a name and specify the full URL (the absolute URL, not a relative URL like /products/general.html) for which you would like to see results.

  5. If you want to track pageviews of more than one URL as part of the same goal, you can click the + button to add another URL.  The goal will fire when it matches ANY of the tracked pages.


     
  6. When adding a URL, you have the ability to specify a match type. The match types will define where the pageview goal is targeted. For more information on match types, see our URL Targeting article, which uses the same URL match types.

  7. Click Save to add the goal to your experiment.  Then save your experiment.  

Pageview goal match types

  1. Simple match: A page or set of pages with any query parameters that may be added to the URL. For example, here's how to track pageviews for your order confirmation page:


    Simple match will target a page with any additional query parameters. This means that the goal above will fire when a visitor lands on www.mystore.com/thankyou.html and as well as URLs like www.mystore.com/thankyou.html?thankyou=1

  2. Exact match: A page or set of pages with specific query parameters that you define. For example, you could track pageviews of your video pages for visitors coming from certain referral campaigns:


    Exact match will target a specific page with distinct query parameters. In the example above, the goal will only fire if a visitor lands on mystore.com/video.html?utm_medium=email

  3. Substring match: Any page that contains the particular string that you choose. For example, you could track pageviews to an entire subdomain (such as blog.mystore.com) or subcategory (such as /blog/) of pages:

    The goal above will fire as long as the URL a visitor lands on contains either of these subsections.

Advanced: Regular Expression match pageview goals

A regular expression match URL goal will track any URL that matches a particular regular expression. Use this match type when your pageview goal is too nuanced to be captured with multiple simple, exact, or substring matches.

How is a regular expression URL goal different than typical regular expressions?

There are a few things you need to do when using regular expression goals that are different from the targeting regular expressions. In particular:

  • Always be sure to escape special characters that appear in a URL with a backslash ("\"). This includes forward slashes ("\/") and question marks ("\?"). If you do not do this, these special characters will be considered part of the regular expression, with unintended consequences.
  • Use all lowercase.
  • Do not include http:// or https:// in the regular expression.

What special characters can I use in my regular expression?

Wildcards:
.   Match any character
\w  Match a word character (alphanumeric plus "_")
\W  Match a non-word character
\s  Match a whitespace character
\S  Match a non-whitespace character
\d  Match a digit character
\D  Match a non-digit character
\t  Match a tab

Repetitions (also known as quantifiers):
*      Match 0 or more times
+      Match 1 or more times
?      Match 0 or 1 times
{n}    Match exactly n times
{n,}   Match at least n times
{n,m}  Match at least n but not more than m times
 
 
Example:

Let's generate a regular expression that targets a range of URLs similar to 

http://playground.optimizely.com/pro...e/confirmation

while applying the following four conditions:

  • In the "playground" subdomain,
  • within the "product" subcategory,
  • on the "confirmation" page,
  • and ignoring the "type."

To generate an expression that includes the three desired terms above, we precede each term with the "." wildcard followed by the "+" quantifier.  The wildcard ensures a match with any characters that follow and the quantifier ensures that the term appears at least once. The final regular expression is:

.+playground.+product.+confirmation

This will match all URLs containing the words "playground," "product," and "confirmation" at least once.

Finally, use the URL Match Validator (below) or a regex editor like rubular.com to verify the functionality of the expression.

For another regular expression match example, check out our article on URL Targeting

 

Still having trouble? File a support ticket with the details and we'll do our best to help!