AudienceView Connect

Use Case Five (GTM) – Pushing Customer Search Input into Google Analytics

Knowing what your visitors are searching for on your website and how successful they are in finding what they looked for is incredibly valuable behavioural information. Google Analytics has a suite of reports dedicated to analysing search behaviours on your website. To configure site searching reporting in Google Analytics we need to tell Google where to get the users’ search input from and this is where we hit a bit of problem. Google expects to find the search input in the URL of the page. If your visitor searched for Wizard, Google expects to see something similar to online/default.asp?search=Wizard in the URL.

AudienceView’s method of submitting the user search does not put the search input in the URL. If I search for Wizard the form is submitted and the URL will remain as online/default.asp. Technically speaking, AudienceView uses a POST submission rather than a GET; however, we can use Google Tag Manager to make up a URL that does include the search input. This is called a Virtual Page Path; with this method we send a page view to Google Analytics and tell Google Analytics to use the made up URL rather than the actual URL.
 
Actual Page View Made Up Page View
Online/default.asp Online/default.asp?q=Wizard


There are other scenarios where you may want to send a Virtual Page Path to Google Analytics. For example, perhaps you want to track that a visitor has seen a particular feature article on the page. You could use a Virtual Page Path to send a pageview to Google Analytics.
 
Actual Page View Made Up Page View
Online/default.asp Online/default.asp?sawarticle=MembershipUpsell


No data is being changed within AudienceView with this approach. This is just an exercise in manipulating the data that is sent to Google Analytics. Let’s take a look at how we would setup Google Analytics site search and then create a tag to send the required data.
 

Implemention

The video below demonstrates the steps required to complete this use case. Please watch the video in conjunction with the documentation.


 
Warning
This tag configuration will send an extra page view to Google Analytics when a visitor searches online. In your Google Analytics page view reporting you may choose to filter out these page views.
 

Configuring Google Analytics Site Search

Site search is turned on in the Admin section of Google Analytics and is turned on per configured view. Navigate to the view that you wish to configure, turn on site search and enter a query parameter. In this use case we will use a query parameter of q.

Site-Search.jpg
 

Required Variables

We need two pieces of data to make up a page path that contains the search criteria: the page URL and the search input.

The Search Input

  1. Choose the option to create a new variable.
  2. Give the variable a name of avPage-search_criteria.
  3. Set the 'Variable Type' to Data Layer Variable.
  4. Set the 'Data Layer Variable Name' to av.page.search.criteria.search_criteria.
  5. Set the 'Data Layer Version' to Version 2.
  6. Leave the 'Default Value' blank.
  7. Save the variable

The Page URL

  1. Choose the option to create a new variable.
  2. Give the variable a name of avPage-page_script.
  3. Set the 'Variable Type' to Data Layer Variable.
  4. Set the 'Data Layer Variable Name' to av.page.page_script.
  5. Set the 'Data Layer Version' to Version 2.
  6. Leave the 'Default Value' blank.
  7. Save the variable.

Required Triggers

We only want to fire this tag when visitors have searched for something. Since we are capturing what they searched for in a variable, we can use that variable in our trigger and fire the tag when the search criteria contains something more than nothing. In technical terms, this is condition where the search criteria does not equal null.
  1. Choose the option to create a new trigger.
  2. Give the trigger a name.
  3. Add a condition for {{avPage-search_critiera}} does not equal null.
  4. Save the trigger.

Configuring the Virtual Page Path Page View Tag

  1. Choose the option to create a new tag.
  2. Give the tag a name.
  3. Choose the Google Analytics – Universal Analytics tag type
  4. Enter your 'Web Property ID'.
    You get this from your Google Analytics account.
  5. Set the 'Track Type' to Page View.
  6. Expand 'More settings'.
  7. Expand 'Basic Configuration'.
  8. Check the box next to 'Virtual Page Path' and enter {{avPage-page_script}}?q={{avPage-search_criteria}}.
  9. Add a 'Firing Trigger' and choose the trigger you created for {{avPage-search_criteria}} does not equal null.
  10. Save the Tag.
  11. Preview your container.
  12. Navigate to your website in a new browser window.
  13. Use Google Tag Assistant to confirm that your Page View tag is firing on every page of your online.
  14. Use Google Analytics to confirm that your page view data is reporting.
    Google Analytics is time delayed. It could be a few hours before you start to see data in your reports.
  15. Publish your container and make your tag live.

Summary

We created a tag that fires when visitors search for something on the AudienceView online using the search input box. This tag sends a page view to Google Analytics but transforms the URL sent to be the page URL plus the search parameters. We configured Google Analytics to use site search reporting and look for the presence of ‘q’ to indicate the visitor’s search input.