Forum Moderators: phranque

Message Too Old, No Replies

Ignoring certain string variables

Ignore string variables for Google Adwords tracking code &gclid=

         

skipunda

2:28 pm on Apr 17, 2009 (gmt 0)

10+ Year Member



Hi,
I've been silently stalking these forums for quite some time now, picking up on the expertise of some of you people, particularly one jdmorgan...I now have my own question!

The only way to explain my problem is to start at the top. If Apache is not where the problem lies then please tell me and at least I've discounted something.

Google Adwords has a tracking service. This service allows me to see the conversions of my Google Pay Per Click's. At some point along the tree of my site is a page where I have put a bit of Google code. When the user hits this page Google will know that a conversion has taken place. Adwords of course needs to put a variable on the end of each of my URL's which only appears for PPC customers as a session ID.

The session ID looks like this
www.example.com/ferraris/niceferraris&gclid=5A4278937638762 (or some alphanumeric)

Understand? Simple enough I'd have thought.

My website doesn't work properly with this variable though. It tries to lookup in the DB, build this page and as a result shows nothing because it's made a page called niceferraris&gclid=5A4278937638762

Can we get Apache to ignore &gclid= and also anything alphanumeric that appears immediately after it, A-Z 0-9. I have php code that will take any bad URL to the homepage but that of course doesn't allow my Tracking - the customer wouldn't be able to go anywhere!

What I don't want though is for someone to write any other string on the end such as &listdatabasefields (if you get me).

Now I would try and nut this out but quite simply I cant. I'm willing to learn though which is the main thing.

Can you help?

jdMorgan

2:45 pm on Apr 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please check that URL carefully, as it is malformed. There should be a question mark after niceferraris and before "&". Is that not the case?

Jim

skipunda

2:59 pm on Apr 17, 2009 (gmt 0)

10+ Year Member



Pardon me, yes it's supposed to be ?

nowpc

3:03 pm on Apr 17, 2009 (gmt 0)

10+ Year Member



The URL is malformed as JDMorgan says. So:
www.example.com/ferraris/niceferraris&gclid=5A4278937638762

-- should look like:

www.example.com/ferraris/niceferraris?gclid=5A4278937638762

EDIT: Just ignore me. Haha. :O/

skipunda

3:52 pm on Apr 17, 2009 (gmt 0)

10+ Year Member



The ? replace by & was just a typo by the way. having read more into this I'm thinking this is not something that can be solved by htaccess (or similar) because we already have the URL. It is just that the site is not Processing the URL properly.

g1smd

3:57 pm on Apr 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It looks like your script processes everything after the last slash in the requested URL as if it were a variable value. I am guessing that your script looks at the complete originally requested URL to parse for variable values.

To fix this, change it so that it only looks at everything up to any question mark (if one is present). That's likely a change in your script, not in the .htaccess file.

It is unclear how the requested URL is rewritten to your script, so it is entirely possible that .htaccess could be amended as well as the script to make a more robust solution.

jdMorgan

4:07 pm on Apr 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> only looks at everything up to any question mark

Also, stop parsing the Request_URI if a "#" sign is found before the question mark, just in case you get a Safari user requesting a named anchor (HTML <a name=""> tag) on one of your pages.

Jim

g1smd

4:09 pm on Apr 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Good point. I missed that one.

skipunda

2:57 pm on Apr 21, 2009 (gmt 0)

10+ Year Member



Hi,
So I've actioned some changes to our script, it's obviously querying the DB for the Google variable and building a page around it which is nonsense.

What I've asked is that if we allow this variable to be passed through the site but not parsed. I'll then get a nice htaccess file together to return a 404 for any other variable.
As far as I know this'll do the trick

thanks

g1smd

9:02 pm on Apr 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It should be just a question of modifying the URL detector so that it grabs only the right part of the URL and ignores any and all appended junk.

Interestingly, regarding your initial typo, I sometimes do see real requests for

/somepage[b]&[/b]param=value
and have specifically added a 301 redirect to catch it and redirect to
www.example.com/somepage[b]?[/b]param=value
for all.

skipunda

7:14 am on Apr 22, 2009 (gmt 0)

10+ Year Member



If there is already an existing variable then the '&' is used. If there is no existing variable then it is '?' Sites must be set up to accept this behavior.

Noton

4:55 pm on Apr 22, 2009 (gmt 0)

10+ Year Member



skipunda,

Just login to your adwords account and go to this page:

[adwords.google.com...]

Click ( edit ) to Change:

Tracking - edit
Auto-tagging: Yes

To No, and this will remove the gclid from your URLs. Google adds these in by defaults for 2 reasons, 1 to help prevent traffic from your AdWords increasing your SEO ranking and 2, which is the publicly used reason as Google Analytics by default can't read traffic from AdWords without this tag.

So while doing this will remove the gclid problem from your site, it will also mean if you are using Google Analytics to track the traffic from AdWords it will no longer be tracked separately and will be considered SEO traffic in the reports. So the traffic is still 100% tracked, it is mixed in with the SEO traffic.

For conversion tracking you can still use the AdWords conversion code on your website and it will work 100% without problems as it works on cookies not URL patterns.

Hope that helps solve your problem.

Stephen

skipunda

8:38 am on Apr 23, 2009 (gmt 0)

10+ Year Member



Stephen,

Many thanks for your reply, and to everyone else who has posted to my problem.

Yes your absolutely right you can (and I temporarily have) removed Google Auto-Tagging.
I reckon this was auto-enabled when I first started using Analytics.

I didn't know that about Adwords using Cookies. I know it was an analytics thing but I thought it would help adwords also.

Thanks
Chris