Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    htaccess for passing Google gclid parameters

    Hi Folks.

    I'm just not understanding how to do what has to be done to get Google Adword's gclid parameters to pass upon redirect on a website.

    Normally, users who arrive like this:
    www.MyDomain.com
    ...are seeing the default page:
    www.MyDomain.com/index.php

    The Google Adword users are arriving like this:
    www.myDomain.com?gclid=12345
    ...but the "gclid=12345" is being lost and users are seeing:
    www.MyDomain.com/index.php

    So...what do I need to do to keep the "gclid" parameter intact , like this:
    www.MyDomain.com/index.php?gclid=12345

    In this case, I need to execute this with a .htaccess file.

    Thanks in advance.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Are you redirecting the request to index.php? If so you just need to add the [QSA] flag to your RewriteRule.

  • #3
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Inigoesdr View Post
    Are you redirecting the request to index.php? If so you just need to add the [QSA] flag to your RewriteRule.
    I am, but I have no .htaccess file with rules at all yet. I'm starting from scratch.

    J

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    How are you redirecting the page then? In PHP?

  • #5
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Inigoesdr View Post
    How are you redirecting the page then? In PHP?
    Pardon the ignorance.

    I'm not exactly sure of the current mechanism. The site is hosted at Hostway, a third party. I assume that URLS that arrive to the site without a page in the address are automatically translated to index.php. It is running Linux/Apache.

    For reference, I am familiar with the mechanism in Mac OS X Server, but not at this hosting company.

    HTH

    J

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Just to be clear, you're saying you go to "www.myDomain.com?gclid=12345" and the URL changes to "www.MyDomain.com/index.php" correct? If that's the case you need to find out what is causing the redirection and alter it to append the query string or preemptively redirect the user with a rewrite when it contains the gclid.

  • Users who have thanked Inigoesdr for this post:

    jbschwartz (05-26-2011)

  • #7
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Inigoesdr View Post
    Just to be clear, you're saying you go to "www.myDomain.com?gclid=12345" and the URL changes to "www.MyDomain.com/index.php" correct? If that's the case you need to find out what is causing the redirection and alter it to append the query string or preemptively redirect the user with a rewrite when it contains the gclid.
    You describe the situation correctly.

    It is the latter I am attempting to do to resolve the issue (create a rewrite rule using .htaccess). This is what the tech folks at Hostway recommended. I don't believe I have access to the mechanism that is stripping the query string.

    So...we're back to the original question: how to create the htaccess rule.

    Thanks for your continued help.

    J

  • #8
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Ok. I took a shot. Here's my attempt...which doesn't work...

    RewriteEngine on <br>
    RewriteRule ^www.mydomain.com?gclid= index.php [QSA]

  • #9
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Here's another try...


    RewriteEngine on <br>
    RewriteRule ^http://www.mydomain.com/?gclid= http://www.mydomain.com/index.php [QSA]


    Looking for end result where the gclid parameter is passed through instead of being stripped.

  • #10
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Try something like this:
    Code:
    RewriteEngine On
    RewriteCond %{QUERY_STRING} gclid
    RewriteCond %{REQUEST_URI} !^/index.php
    RewriteRule ^(.*)$ /index.php [R=301,QSA]

  • Users who have thanked Inigoesdr for this post:

    jbschwartz (05-27-2011)

  • #11
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Inigoesdr View Post
    Try something like this:
    Code:
    RewriteEngine On
    RewriteCond %{QUERY_STRING} gclid
    RewriteCond %{REQUEST_URI} !^/index.php
    RewriteRule ^(.*)$ /index.php [R=301,QSA]
    Wow! That worked exactly as desired! Thanks!

    Where do I donate?

    Jonathan


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •