Home » Proxy Articles » Installing Google Analytics on PHProxy

Proxy Lists Proxy Articles Proxy Scripts Submit Proxy Advertise Contact Us News Bot Privacy Policy Proxy of the Day Advertisements

When it comes to tracking traffic usage on a web proxy one of the most obvious choices is to use Google Analytics. Installation of the code is fairly simple on PHProxy and can be completed in two steps.

First you need to decide which version of the code you are going to utilize. Google now offers two versions of the JavaScript code for you to select from...

ga.js


<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-XXXXXX-XX");
pageTracker._initData();
pageTracker._trackPageview();
</script>

urchin.js


<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-XXXXXX-XX";
urchinTracker();
</script>

The steps for installation are the same regardless of which JavaScript code you decide to use. We will be using the "urchin.js" version of the code as we have found that the newer "ga.js" is suspect to error and does not track as effectively.

You now need to open the template file in a text editor such as Notepad, the file is typically called "index.inc.php" in most non-customized installations. When you have it open you need to scroll to the bottom of the file and find the HTML Body end tag which looks like this:

</body>

You need to paste in your JavaScript code directly above that HTML tag, save and upload the file to your hosting account.

The next step is to edit the "index.php" file itself. This can seem a little daunting for non-programmers as the file is very large and complex. Once you have the file open scroll right to the very end and look for a line which reads:

$_url_form.= "</form></div>";

You will see that in this case all of the HTML is assigned to what is called a PHP Variable which is named $_url_form. You will need to place your JavaScript code directly after the aforementioned line, but before you do you need to assign the JavaScript code to the PHP Variable in the same way the HTML is assigned and then escape any quotes.

To make your life a little easier below are the JavaScript codes already prepared, you just need to replace the UA-XXXXXX-XX with the tracking number from your account.

ga.js Prepared for PHProxy "index.php"


$_url_form.= "<script type=\"text/javascript\">";
$_url_form.= "var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");";
$_url_form.= "document.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));";
$_url_form.= "</script>";
$_url_form.= "<script type=\"text/javascript\">";
$_url_form.= "var pageTracker = _gat._getTracker(\"UA-XXXXXX-XX\");";
$_url_form.= "pageTracker._initData();";
$_url_form.= "pageTracker._trackPageview();";
$_url_form.= "</script>";

urchin.js Prepared for PHProxy "index.php"


$_url_form.= "<script src=\"http://www.google-analytics.com/urchin.js\" type=\"text/javascript\">";
$_url_form.= "</script>";
$_url_form.= "<script type=\"text/javascript\">";
$_url_form.= "_uacct = \"UA-XXXXXX-XX\";";
$_url_form.= "urchinTracker();";
$_url_form.= "</script>";

After you have pasted in the code (and changed the tracking code to the one from your account!), simply save the file and upload it to your server and your all done.


Home | Proxy Lists | Proxy Articles | Proxy Scripts | Submit Proxy | Advertise | Contact Us | News | Bot | Privacy Policy

Copyright © 2008 - 2010 A-Z Proxies, All Rights Reserved.