Home

gloucestershire.gov.uk uses cookies to make the site simpler.
Find out more about cookies

Skip to main content
Log in to the appropriate Umbraco address
If you are editing a subsite read this

Using advanced filters and segments

First you need a clear understanding of the difference between Report Filters and Site Segments:

Report Filters: allow you to filter the items on a report based on some dimension or metric in that report - they look at items in the rows of the report table like 'Page' and 'Page Views'.

Site Segments: allow you to to filter traffic (like 'Users' or 'Sessions') that fits some non-metric/dimension criteria like 'sessions that have visited page X' or 'users between 55 and 64'. These do not filter based on the content of the report.


Filtering

So far we've used simple searches that allow you to use a single word or phrase & filter the report. This is fine for the quick reports discussed on the 'Google Analytics' page but the filters are too restrictive for most reports. Google Analytics offers advanced filters to allow more targeted filtering.

Advanced Search

Open the 'Advanced' link next to the search box to slide open the advanced search options.
(If you leave an existing search in the simple search box Google will transfer this to the advanced search.)

Advanced Search

This slide-out has three selectors and a text box that allows for quite powerful queries.


  • Include/Exclude Selector (self explanatory)

  • Dimension/Events/Usage selector: Offers a list of items on which you can filter - this list will change depending on which set of data you are examining:
    Dimension/Usage selectorDimension / Event / Usage selector

Depending on the list you are presented with you may be able to filter your list by:

Dimensions: Such as 'Page' - the URL fragment already discussed in the Google Analytics section, so for a page with the URL 'http://www.gloucestershire.gov.uk/fostering/can-i-foster/can-i-foster/' the 'Page' would be '/fostering/can-i-foster/can-i-foster/'

Site Usage metrics: allows you to filter out based on the value of various metrics; for example filter to show only pages with unique page views fewer than X for the period selected (finding low traffic pages).

Event metrics: again allowing filtering by the value of various metrics

E-commerce metrics: also occasionally appear


  • Containing/Comparison selector: Allowing you to use various types of query

The list presented depends on whether the selected item is a string or a number
Containing or Comparison selector

Of these only the 'Matching RegExp' is not obvious. A regular expression looks something like:

^\/fostering\/.*

This uses several common regular expression elements to build a text string that looks for matches to patterns in the text strings in columns of the analytics report table.

This is a very simple version. See 'Regular expressions' for a longer version. Google also has a succint explanation of the basics in Analytics Help and W3Schools has a handy short reference.

Broken down the above string means:

^

This character means start of string so…

^something

…means a string starting with 'something' eg

something/and/something/else

but not

/something/and

…because 'something' is not at the start of the string!

The character '$' serves a similar purpose except you use it to specify 'at the end of the string'. So…

/something/with/this/at/the/end$

…would match…

/this/string/with/something/with/this/at/the/end

…but not…

/this/string/with/something/with/this/at/the/end/and/the/rest

\/

This is two characters (not a 'V') - '\' in RegExp means the next character is as entered, even if it would normally be treated as a 'special' character. Doing this is not required for a forward slash '/' but is both harmless and safer than assuming a '/' won't be treated as 'special'.

So this pair reads as a /

You must use '\' before the following special characters

\ . $ ^ { [ ( ) | * + ? 

So to search for 'index.aspx' you would have to use 'index\.aspx'.

fostering

Just a character string

\/

Reads as /

.*

Formed of two characters with special meanings (note that they are in the 'special' list above)

. - the dot character means 'any character'

* - the astersik/star character means repeat the previous character 0 or more times

Together they mean a string of any number of any characters (anything or nothing).

You can also specify:

.? - to mean zero or one of any character
.+ - to mean one or more of any character
.{X} - to mean exactly X of any character
.{X,Y} - to mean between X and Y of any character

The…

^\/fostering\/.*

…Regular Expression therefore reads as:

Start with '/' followed by 'fostering' then another '/' followed by any characters you like (or none).

'How many 'hits' did our 'HR Handbook' on Staffnet get for the final quarter of 2017?'

Process:

  1. Locate the 'HR Handbook'
    This can sometimes be harder than it sounds. In this case it is fairly obvious what 'HR Handbook' means, and at least the question includes the system the client is referring to, but sometimes the requirement will be vague ('our commercial pages') so you need to establish precisely what the client wants before wasting any time capturing the wrong data. You need to know:
    1. System - Staffnet or web & if web which sub-site
    2. Precise URL of the page
    3. Is this a 'section' request, ie does the client want all traffic to all pages in a particular section or do they want traffic for a particular page or pages
  2. Establlish the URLs for which you will be gathering data
    In the case of the 'HR Handbook' request we are going to assume that this is:
    https://staffnet.gloucestershire.gov.uk/employee-information-and-support/hr-and-employment-handbook/
  3. Open the appropriate view in Google Analytics
    view menu
    open view
  4. Locate the 'All Pages' report in:
    Behaviour → Site Content
    all pages report
  5. Adjust this so that it shows 'Unique Pageviews' on the graph and set the date range to 01-Oct-2017 to 31-Dec-2017 (final quarter).
    This now shows the metric you are looking for (Unique Pageviews = 'Hits'), but for the whole of Staffnet.
  6. Open advance filters and choose 'Include' - 'Page' - 'Matching RegExp'
  7. Construct your filter - for this sort of report you need an advanced filter to ensure you only get the pages in the 'HR Handbook' so
    1. I want it to start with...
      '/employee-information-and-support/hr-and-employment-handbook/'
      ...so we need to start the string with '^'
    2. ...and show all pages from there downwards
      ...so I need to end the string with '.*'
    3. The filter is therefore:
      ^/employee-information-and-support/hr-and-employment-handbook/.*
  8. Hit 'Apply' and review the result (use the 'Show rows' selector below the table to expose all the rows in the reports)
  9. This example shows relatively clean results so there is nothing else to do other than:
    1. Export the report in a suitable format (or email it to your client)
    2. Save the report if you will need to use it again

Segmenting

Segments allow you to restrict the activity under report to things which are not dimensions or metrics on the report. A good example of this is how you answer the question 'How many 'people' visited our page'.

As you can see the Audience overview report shows 'Users' which is the best measure of how many 'people' visted your site. A less useful measure is 'Sessions' which tracks indivdual visits but not whether the visit is from someone who has been there before (a User).

However, your page does not appear anywhere on this report which also has no explict 'filter' option. To find how many of the users on this report visited your page you need to apply a segment before running the report.

Audience overview

You can add an edit segments from the segment panels above the report. If you believe that the segment exists, hit the 'All users' panel & you'll see a list from which you can select. It's possible to select more than one segment but you need to know what the effects will be if you are going to do this.

If you need to set up a new segment, hit the red button. The configuration panel offers options for:

  • Demographics - characteristics of your visitor such as age or gender
  • Technology - what are they using to browse your page
  • Behaviour - how often they visit and conduct transactions
  • Date of First Session
  • Traffic Sources - by how they found you (allows campaign tracking  but you need to tag your links to use this)
  • Advanced
  • Conditions - restrict users and/or their sessions according to single or multi-session conditions (this is the method you would use to restrict the segment to users who had visited your page - see the worked example below)
  • Sequences - sessions according to sequential conditions

The simple options are obviously simple to set up so here we just consider how to use advanced conditions to filter to  users with other characteristics.

'How many 'people' visited our 'HR Handbook' home page on Staffnet in the final quarter of 2017?'

Process:

  1. Open the 'Audience overview' report shown above
  2. Select 'Users' (if not already selected)
  3. Hit the '+ Add Segment' button
    add segment button
  4. If you already have a segment restricted to users who have visited your site, find & select that
  5. If not, hit the red '+ New segment' button
  6. Go to Advanced → Conditions
    advanced conditions
  7. In the 'Conditions' panel switch the filter to 'Users' and 'Include'
  8. On the second row find
    • 'Page' in the first drop-down
    • Select 'matches regex' in the second
    • Add the following regex in the box
      ^/employee-information-and-support/hr-and-employment-handbook/.*
      This should be an expression you can read if you've gone through the 'Regular Expressions simple explanation' above.
      It means pages at or below:
      /employee-information-and-support/hr-and-employment-handbook/
    • As you add the regexp you should see that the summary percentage changes from 100% to a proportion that represents what percentage of users have visited the /employee-information-and-support/hr-and-employment-handbook/ area on Staffnet - if it is 100% or 0% you've done something wrong; check your regexp
  9. Give it a segment title & save
  10. Google automatically applies the new segment to the report
  11. Set the required dates for 'final quarter 2017'

You have your answer: roughly 2000
(Remember the accuracy limitatons of Google Analytics)

finished audience overview report


 

Help us improve Gloucestershire County Council

Don’t include personal or financial information like your National Insurance number or credit card details.