question regarding redirect, masking, analytics

by csrpj
2 replies
i have URL that redirect to my affiliate link.

so mysite.com redirects to affiliatesite.com/?ref=myusername

but i want my site to redirect to affiliatesite.com with the "?ref=myusername" shown.

is there a way to do this?

i also have another problem..... i'm trying to get google analytics on my site, but given the redirect script i can't seem to make that happen. google analytics requires some code to be pasted on the page i wish to track, yet the simple php redirect doesn't seem to function if there's other stuff in the code! how can i reconcile?
#analytics #masking #question #redirect
  • Profile picture of the author EarnBig
    Hmmm

    So let me get this right, you want your users to see this AFF link on your site:

    mysite .com/?ref=myusername

    And when a user clicks they are redirected to:

    affiliatesite .com/?ref=myusername

    One of the easiest ways to do this is to edit your sites index.php file and create a header redirect with an IF statement. Right at the very top of the file add this:

    <?php
    $kw = $_GET['ref'];

    if ($kw == "myusername")
    {
    header( 'Location: affiliatesite .com/?ref=myusername' );
    }
    ?>

    If you don't want to edit your sites index.php file, an EASY alternative would be to do this. Create a PHP file and call it whatever you want, say "go.php". Place it in the root of mysite .com, then place a simple redirect within the go.php file like this:

    <?php
    header( 'Location: affiliatesite .com/?ref=myusername' ) ;
    ?>

    Then use this for your AFF link:

    mysite .com/go.php?ref=myusername


    The Analytics code, not sure about this without looking at the PHP file your redirect script is using. However, the best place for the Analytics code is at the BOTTOM of the HTML or PHP page just above the </body> tag. Google's Analytics server can sometimes overload causing your page to stop loading in the users browser if the code is in the header - so place it at the bottom.


    Hope this helps.

    Note to admin/mod: Site doesn't let me use PHP BBCode tgs with less than 15 posts.
    Signature


    Outsource your projects :: Hire Workers and Freelancers ::
    (Step up to the next level)!

    Add me on Twitter :: @EarnBig
    {{ DiscussionBoard.errors[2252083].message }}
  • Profile picture of the author wsylvester
    Google analytics runs through javascript. In theory you place this on your landing page, and with your redirect this runs when the user ends up on the destination page. You can use your server logs to understand the number of "redirects" unless you were trying to use google's goals to identify affiliate tracking. IMHO- not a very trustworthy way considering you lose the tracking if the client doesnt support javascript. You can also do a meta-refresh but if your timing is off you may not get the record of the impression.
    {{ DiscussionBoard.errors[2272093].message }}

Trending Topics