Jump to content

google analytics regex match help


nikefido

Recommended Posts

Hi -

 

Google anlaytics lets you match URLs in order to set a goal.

 

For instance, this is a goal for us that lets us know someone successfully submitted a contact form:

 

/[somefilename].php/submit1=true

 

We need to match the [somefilename] with any text (valid file name). Currently we have:

/[A-Za-z0-9_].php?submit1=true

 

However, this isn't working.

 

variations include:

/^[A-Za-z0-9_]$.php?submit1=true

^\/[A-Za-z0-9_]\.php?submit1=true$

 

and others...

 

The Filenames don't have special characters, do contain underscores and are mixed case.

 

For some reason I can't get this seemingly simple regex match to work :( (Been testing with PHP's eregi / preg_match functions)

 

Can anyone help match this pattern successfully?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/166977-google-analytics-regex-match-help/
Share on other sites

preg_match('~^/[A-Za-z0-9_]+\.php\?submit1=true$~D', $url);

Notice the + quantifier, meaning one or more of the previous character (a character class matches one character), and that I escaped the special characters (the dot and the question mark).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.