Skip to main content

Optimize based on Paid Ad Campaigns or SEM

  • Updated

This topic describes how to:

  • Use query parameter targeting in Optimizely Web Experimentation to target visitors from certain ad campaigns.
  • Understand what query parameters are and how query parameters are used in SEM.
  • Create symmetric messaging experiments based on query parameter targeting.
  • Use Optimizely Web Experimentation in tandem with Search Engine Marketing (SEM) query parameters from platforms like Google AdWords to optimize your site for inbound search traffic.

URLs can contain a lot of information, and one of the most common components is the query string. Query strings contain many pieces of information, and you can use them in Optimizely Web Experimentation to personalize your experiments.

What are query strings and parameters?

The query string is the part of the URL that comes after a “?” and contains data to be passed from the URL to a web application. Query strings consist of query parameter name and value pairs (for example, ?name=value). Multiple query parameters are separated with an “&”.

Example:

A query string looks like the following in a URL (the query parameters are italicized):

www.example.com/?nameA=valueA&nameB=valueB&nameC=valueC

Where do query parameters come from?

Some of the most common query parameters are generated by interaction with search and ad campaigns. For example, when you integrate Google AdWords campaigns with Google Analytics, you can tag your user’s URL with query parameters to pass data to Google Analytics.

There are two common forms that query strings take:

Manual Tagging

Selecting Manual Tagging lets you build your own query string and will take the form “?utm_source=google&utm_medium=email&utm_name=winter_clearance”. This contains less visitor information than auto-tagging (see below) but is more easily transferred to third-party platforms like Optimizely. See this Google support article for more detail.

  • utm_source. The campaign source, like a search engine, newsletter, etc.
  • utm_medium. The campaign medium, like email or PPC campaign
  • utm_term. The keywords for this campaign, used in paid search
  • utm_content. Can differentiate ads or links that point to the same URL, especially useful if you’re A/B testing your ads/links to see which one is more effective
  • utm_campaign. Identifies a specific campaign or promotion

Auto-tagging

If you select Auto-Tagging in AdWords, then your URL is appended with a Google click ID that looks like “?gclid=12345”. This contains all of the information from the manual tags (see above) and other data that is passed into Google Analytics.

There is also the option to use a combination of the two tagging methods, which can provide the best of both approaches - more data pushed to GA and more flexibility in Optimizely Web Experimentation's targeting. See also Tag your Google Ads final URLs.

What can I do with query parameters in Optimizely Web Experimentation?

The most common use case for query strings in Optimizely Web Experimentation is to target experiments to run only on visitors who have interacted with your ad campaign. You can set an Audience Condition on the appropriate query parameter

audience-utm-campaign.png

You can even leave the “value” field blank to include all values for a given parameter name if you like. For example, if you target the parameter name utm_campaign and leave the value field empty, it will include visitors who have ?utm_campaign=spring_clearance, ?utm_campaign=holiday_sale or any other parameter value.

When you use Manual Tagging or the combination method, your options for targeting experiments in Optimizely Web Experimentation increase dramatically.

With certain plans, you have the ability to segment your experiment results. This makes it extremely easy to compare the behavior of visitors from various campaigns. For more information about which segmentations are available to you, please refer to our Optimizely Web Experimentation package matrices.

Example: Using Query Parameters for Personalization and Symmetric Messaging

In this use case, we will use query strings for personalization. This technique is known as “symmetric messaging” because it will use information from a visitor’s search terms to personalize the experience on your site.

See an example of symmetric messaging in action in this blog post by Optimizely's Steve Ebin on the impact of symmetry on Optimizely Web Experimentation's PPC landing pages.

This use case involves a little more of a technical implementation, but you can avoid this technical work by using the Google AdWords integration (available on select Optimizely Web Experimentation packages).

Suppose you are using manual or combination tagging and you are passing search terms to a query parameter using utm_term={keyword}. With a short bit of code, you can grab that keyword from the visitor’s URL and render it on the page, ensuring a consistent experience for your traffic from search engine to landing page (and even further if you want!).

The following defines a function that will retrieve the value of a query parameter you pass in.

function getParameterByName(name) {
   name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
   var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
   results = regex.exec(location.search);
   return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
  }

In Optimizely Web Experimentation, you can place the code in the experiment's Custom Code. Enable jQuery in project settings or include it in your code. See also jQuery and the $ variable in Optimizely Web Experimentation.

Call the function in the <edit code> box, telling it which parameter’s value it should retrieve and where it should render on the page. The function call may look like this:

$("h1 > span").text(getParameterByName(“utm_term”));

utm-term-split.png

In this case, you pass in the string “utm_term” to the function, which then retrieves the keyword value “Split”. Calling this function in your variation code, all elements with jQuery selector “h1 > span” on the page will be changed to “Split.”