How to add google analytical code inside a domain that has no webpage?

6 replies
I did the steps below as advised by a fellow warrior, creating php file, adding link (shown below). But when i entered google analytics, they require me to add a code to my webpage which i do not have at all. Any warriors can advice me?

Regards.



Here is how I create a PHP redirect:

1) Create a file called myaffprogram.php where myaffprogram is the name of the product or program you want to promote.

2) Copy and paste the following code into it:

Code:

<?php
header("Location:http://www.yourafflink.com");
exit();
?>

3) Replace the link with your affiliate program ID.

4) Upload the file to your host and the link will be yourdomain.com/myaffprogram.php

Every time someone clicks on this it will show up in your stats.
#add #analytical #code #domain #google #inside #webpage
  • Profile picture of the author ExRat
    Hi,

    they require me to add a code to my webpage which i do not have at all
    Create a file called myaffprogram.php
    The file 'myaffprogram.php' is the webpage that you need to add the GA code to.

    I can't guarantee it will work, I've never tried adding google analytics to a redirect page.
    Signature


    Roger Davis

    {{ DiscussionBoard.errors[886876].message }}
    • Profile picture of the author xiaophil
      When they said "it will show up in your stats", I think they meant the log files on your host, not Google Analytics.

      Most hosting companies provide a way to view your logs in a friendly way from the control panel, take a look.

      I've never tried G.Analytics with a php redirect either. If it doesn't work then you could try a blank html page with an http meta-refresh.
      {{ DiscussionBoard.errors[887189].message }}
  • Profile picture of the author Harry Behrens
    When using a PHP redirect Analytics will not track because the PHP fires first, and doesn't give any time for the Google Analytics code to activate.

    You would need to use a javascript redirect that is placed below the Analytics code:

    <script type="text/javascript">
    <!--
    window.location = "http://www.google.com/"
    //-->
    </script>
    You can read more about it here (no affiliation): Javascript Tutorial - Redirect

    Im fairly sure this would work, however, in full disclosure I have not tried it myself first-hand... worth a shot though
    Signature

    - Harry Behrens

    {{ DiscussionBoard.errors[887239].message }}
    • Profile picture of the author ExRat
      Hi hmbehrens,

      When using a PHP redirect Analytics will not track because the PHP fires first, and doesn't give any time for the Google Analytics code to activate.
      I thought that would be the case. Bearing in mind all of the javascript issues this might create and possible lost commissions, depending on what exactly the OP wants to achieve, wouldn't it be better just to use a typical, stat-producing redirect script?
      Signature


      Roger Davis

      {{ DiscussionBoard.errors[887261].message }}
  • Profile picture of the author Harry Behrens
    Yep it'll cause the usual javascript stuff like if the browser has its javascript disabled, the redirect won't happen and the browser will just stay frozen on the empty page. When talking of conversions and sales that can definitely be a deal-breaker.

    I'm assuming we're talking about a domain that's entirely redirected with a single page (like for example to get around ezinearticles.com linking restrictions or something like that) so that's the only solution I can think of aside from, like you suggest, using an actual stats and redirection script and cutting out Analytics entirely... I don't have much experience with those scripts though so I can't recommend any.
    Signature

    - Harry Behrens

    {{ DiscussionBoard.errors[887277].message }}
  • I would just use the analytics software within Cpanel or if you require something more powerful, there are off the shelf software packages that you can install on your host (if you have root access), that will provide you similar results like analytics.
    {{ DiscussionBoard.errors[890721].message }}

Trending Topics