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
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).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.