Question : regular expression

Hi All,

I have a client who is starting a google adwards campain, what I need to do is track the whether people are coming directly to the site, or doining a google serach or clicking on a google adwards campain link.

I have written code to setup sessions to track whether someone has come directly to the site or if they were refered from another source.

What I need to do now is see whether the person came by clicking on the google adwards link. I have had a look at the google webmaster tools and it allows you add url variables to be part of the destination address please see below for an example of the kind of url I will be using. I want to able to use preg_match check to see if "adwards  or  utm_medium=adwards" is part of the refering url.

could someone please show me how I would write the regular expression (new to regular expressions) so that preg_match will pick up if "adwards" is present in the referrer url.

http://www.<a_clinets_page>.com/utm_campaign=retirement&utm_source=google&utm_medium=adwords

Many thanks in advance for your help
Bob

Answer : regular expression

You'll find these page helpful  
http://www.regular-expressions.info/reference.html
http://php.net/manual/en/reference.pcre.pattern.modifiers.php

but you'll want something like

preg_match('/ (adwards|utm_medium=adwards)  /i', $url);

Course the first one will match the second one.
Random Solutions  
 
programming4us programming4us