Need help with GA regex

Hi,
I am trying to setup a regular expression for an “include
hostname only” filter for google analytics and I am not really sure how
to do this for an Australian domain.

Which one of these is correct?

.mydomain(backslash).com(backslash).au

or

.(star symbol)mydomain(backslash).com(backslash).au.(star symbol)

Normally I would just verify the filter but I cannot verify it
because google says the amount of traffic is too small for verification.

Hey could a mod please put this back in the javascript forum where it was originally.

It most definitely does not belong in general web dev.

Only a javascript expert would be able to answer this quetion since it is javascript regular expressions that are used for Google Analytic Filters.

Actually, one could argue that JS regex is based on Perl regex so this should be in Perl

Anyway,

.mydomain(backslash).com(backslash).au

will match eg.

Wmydomain.com.au
3mydomain.com.au
@mydomain.com.au
-mydomain.com.au

i.e. any one character in front of “mydomain”

And

.(star symbol)mydomain(backslash).com(backslash).au.(star symbol)

will match eg.

mydomain.com.au
gobbledygookmydomain.com.augobbledygook
why-mydomain.com.au-ohmy
123mydomain.com.auXYZ
XYZmydomain.com.au123

Looks to me like neither are what you’re after, got a link to the Google Analytic Filters documentation page?

Here is a link to the official documentation

https://support.google.com/analytics/answer/1034324?hl=en

A couple of regex threads were created after mine in the javascript forums and are still there, I have no idea why Pullo moved my thread here, maybe it was due to my lack of code formatting (which I dont have access to yet because my account is too new)

Anyway

to match
mydomain.com.au
www.mydomain.com.au

I would use
/^(www\.)?mydomain\.com\.au/

Which roughly translates to
begins with - the ^
maybe www. - the (www.)?
otherwise mydomain.com.au

the backslash means “.” is the literal character and not the regex “anything” wildcard

thanks for the replies guys, I will give this a shot

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.