Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7015013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:35:50+00:00 2026-05-27T22:35:50+00:00

I have a small script that redirects users to main site if they come

  • 0

I have a small script that redirects users to main site if they come from a banner on my/other remote sites.

<?
.
..
...
....
header("location:$golink"); 
?>

But google analytics will not show the referrer site (where the script is working) instead it shows the url where the banner is clicked. Obviously I can not keep a track of all sites where banner appears and dont want to. I want the refferer to be the site where the script is working. How do I have to use the $_SERVER[‘HTTP_REFERER’]; in order to do this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:35:50+00:00Added an answer on May 27, 2026 at 10:35 pm

    GA has a method that will let you to override the default referring URL (document.referrer) with a specified value.

    So if you want to keep the redirect server-side, you can append the referring URL as a query string param in your header() call, and then look for it on the target page and specify it as the referring URL.

    I don’t know how you are building your $golink variable, but basically you would add something along the lines of:

    $golink .= "?ref=" . $_SERVER['HTTP_REFERER'];

    Use a & instead of ? if there are already URL params, and the code above assumes using ref as the URL param, so use whatever var you want.

    Then on your target pages, before your _trackPageview call, you would add

    _gaq.push(['_setReferrerOverride', ref]);

    ref would be a javascript variable with the value of the ref=xxx query string param. For some weird reason Javascript does not have a native way to grab URL param values, nor does GA provide an (exposed) solution. If you already have a solution on your pages for grabbing URL params (like something from a framework or a function you’ve already made) then use that. Otherwise it’s pretty easy to find a javascript function that will do it for you.

    There are a couple benefits to doing it this way:

    1. You don’t have to worry about the visitor seeing an interstitial page.
    2. You don’t have to worry about GA not getting a chance to fully load before redirect
    3. You can see the referrers tied directly to your landing pages, because with the interstitial page, you will always see that interstitial page as the referrer, and will have to look at referring url reports for the interstitial page.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small script that copies files to a list of remote machines.
I have small script that takes the value from a text input and needs
I have a small PHP script that takes the values from a dropdown list
I have a small script that use urllib2 to get contents of a site,
I have a small PHP script that is selecting a random sentence from an
I have a small script that I am try to port to work for
I have a small cgi script that fetches and validates a configuration file for
I have a script that animates a small DIV popping up on the page.
I have a small script and want to detect the script version from admin
I have a small script that checks a large list of domains for their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.