Google Analytics is a fantastic free tool that allows you to track the effectiveness of your website. You can use Google Analytics along with Regular Expressions to set up advanced filters, set up target tracking or segment traffic. In order to make the most of Google Analytics it is important to understand the basics of Regular Expressions. Regular Expressions is a science that allows you to extract information from your website so you can understand what your visitors do and why they do it.
Contents
With Regular Expressions you can use the below character tools to help you extract the information you need. You can even use a combination of these characters for more specific answers to your search questions.
- Backslash –
- Pipe – |
- The question mark -?
- Parenthesis – ()
- The point -.
- Brackets, stretch and staple – [-] {x, y}
- The star – *
Backslash –
The backslash is probably the Regular Expression you will use the most. Backslash can be used when you want to turn a regular expression into a literal character. Ie. if we have a URL containing “?” the problem is “?” also plays the role of soluble expression. By using , we can remove the function of “?”. It’s called Escape: a character.
Example:
For example say we have a webshop that makes use of different ID numbers in the URLs of each category on the website. Then we can filter such as “Search and replace” (Find and Replace) to provide clearer picture of the people who are not familiar with the site’s URL structure. But a problem arises when we create the filter because the URL contains “?”. By then put a before “?” We remove the function of “?”.
Pipe – |
The pipe or sign symbol acts as an ‘and/or match’. It is often used when website owners want to narrow down the keywords visitors have used to find your site.
Example:
Maybe you would like to compare two different types of visitors to see which ones convert best. Maybe you want to compare those who will find your site with keywords that free and cheap with all other search traffic.
The question mark -?
The question mark is a popular regular expression character. It works to mark a sign or expression of your choosing. Tell us in the keyword report, for example, to filter out the company name. Say your company is called Dance Group, but a common misspelling is Dann group with two n’s. With the help of the question mark we can capture both the dance group and Dann group.
Parenthesis – ()
Using parenthesis allows you to group an expression without affecting the entire string. You can see how this regular expression works by looking at the maths.
- 7 +3 * 3 = 16 – ie. three times three is nine, seven plus nine equals sixteen.
- (7 +3) * 3 = 30 – ie. Seven plus three is ten, ten times three equals thirty.
Perhaps you remember from your maths classes that you must calculate what is inside the brackets first. In this way with Parentheses you can choose the information that is most important to you and your analysis..
- / Folder-one | two / connect = / folder-one or two / contact
- / Folder (one | two) / connect = / map-one/contact or / map-two/contact
Example:
Take as an example a site with various entry fields scattered across the site and the value / information per completed entry field which you want to track. The problem is that the information is in individual destinations and you need to capture / sent, / skickat.html and / skickat.php . In this instance you need to use / sent (. html | . php)?
In this way we can cover all three final destinations. Remember, the question mark makes our brackets “voluntary”, if we were to remove the question mark, we would not get / sent only / skickat.html and / skickat.php. You can see that by using the / sent (. html | . php)? string you can track the same goal (destination) for different entries even though the source is different.
The Dot -.
In Regular Expression a dot is used in place of a character, for example if you want to find the words ending in ‘air’ you can type ‘.air’ and you will get p.air, h.air, f.air matches with any character. A dot is often used together with other expressions.
- Da.is – will match, Dagis , Da.is , Da_is etc etc. But not Daisen .
The dot is in place of any type of character, however there must be a letter after the dot.
Eg; E.il will match Evil. E.vil and E.Vil but NOT Eil. , as there is no letter/character missing between the E and il.
Example:
Say we want to filter out traffic from a certain IP address. If your business would be on all IP addresses from 83.75.140.250 to 83.75.140.255 we would use regular expressions to write 83 .75 .140 .25. In this way all the IP numbers are covered . Although we cover also 83.75.140.256, but this will never happen because there is a proper IP number.
Brackets (brackets), stretch and staple – [-] {x, y}
Brackets are used most often alongside “-” and also quite often together with staples, but can also be used without. We could use brackets in a list of keywords to filter; bracket [abc] and you will see all the keywords that contain a, b, or c. If you wrote a [abc] 2, we see only 1A2, 1B2 or 1c2. The best use of brackets is together with “-”. Then we can use out of the following techniques,
- [Az] – all lowercase letters from a to z
- [AZ] – All capital letters from A to Z
- [0-9] – All the numbers from zero to nine
- [A-oa-o0-9] – all of the above (note that you do not use out of pipe or a comma.)
You’ll get even more use from brackets when you use them alongside staples. If we take the above example again and lay down a wire so we get a [abc] {1,2} 2. So we will now go beyond them in the first example also match 1ab2, 1ac2, 1ba2, 1bc2, etc, etc.
In this way a staple acts to repeat the previous expression between X to Y times.
The star – *
Star is perhaps the characters in regular expressions most often used improperly because it did not really have the same function as it may otherwise have. The star means that you take the preceding character and repeat it from zero to many times. So Baa * st will match words both Bäääääst and Bst. The star itself is perhaps not so useful, but together with the point you can create a unique filter. One of these filters allows you to see the full visitor url address.
Example:
If we create a filter in accordance with the following settings.
- Filter Type: Custom filter = Advanced
- Field A -> Extract A: Hänvsining = (.*)
- Field B -> Extract B : leave blank
- Output To -> Constructor: User Defined $ A1 =
- Field A Required: Yes
- Field B Required: No
- Override Output Field: Yes
- Difference between small and large letters: No.
So we give this filter, then, we could see from the URL, the visitor found our site. The report will then find under Visitors -> User Defined. Remember that the filter first start functioning from the time you created it.
Hopefully you’ve now learned a bit more about Regular Expressions and how you can use it with Google Analytics. We have covered the basics here, if you’d like to know more about specifics just email us with your questions.
Vänliga hälsningar,
Victor Kaugesaar
Direct tel: +46 (0)31 - 788 02 50
www.bebetteronline.se
Be Better Online Sweden AB
Stigbergsliden 7
414 63 Göteborg






READ MORE












We support The Hunger Project
English
Dansk
Suomi
Norsk
Svenska