Difference between revisions of "Google Analytics"

From WHMCS Documentation

m (Reverted edits by John (Talk); changed back to last version by Matt)
Line 1: Line 1:
Google Analytics allows you to track how people find your site, how they navigate through it and how they become customers. You can see trends of pageviews, visits, bounce rate, conversion rate, geographical locations and much more.
+
Google Analytics allows you to track how people find your site, how they navigate through it and how they become customers. You can see trends of pageviews, visits, bounce rate, conversion rate, geographical locations and much more.
  
To integrate google analytics into your WHMCS system, simply follow the 2 steps below:
+
And in WHMCS, we make it easy to use Google's service by providing an addon module which you can simply install & activate to automate the integration process.
  
1. Begin by inserting the code below into your footer.tpl template file before the </body> tag:
+
==Download/Install==
  
<nowiki><script type="text/javascript">
+
To download the latest version of the module, please visit the Official Addon Listing page for it @ http://www.whmcs.com/members/communityaddons.php?action=viewmod&id=314
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"));
 
{literal} try {
 
var pageTracker = _gat._getTracker("UA-xxxxx-x");
 
pageTracker._trackPageview();
 
} catch(err) {} {/literal}
 
</script></nowiki>
 
  
2. And to complete the integration, add the following code to the complete.tpl template file in your active order form template folder:
+
Once downloaded, simply unzip the file and upload the google_analytics folder within it to the '''/modules/addons/''' directory of your WHMCS installation.
  
<nowiki>{php}
+
==Setup==
$orderid = $this->get_template_vars('orderid');
 
$userid = $_SESSION["uid"];
 
  
// get client data
+
The first step of tracking e-commerce transactions with Google Analytics is to enable e-commerce reporting for your website's profile inside the Google Analytics panel:
$result = select_query("tblclients","city, state, country",array("id"=>$userid));
 
$data = mysql_fetch_array($result);
 
$city = $data["city"];
 
$state = $data["state"];
 
$country = $data["country"];
 
$this->assign('city',$city);
 
$this->assign('state',$state);
 
$this->assign('country',$country);
 
  
// get package name
+
#Sign in to your account.
$result = select_query("tblhosting","packageid",array("orderid"=>$orderid));
+
#Click Edit next to the profile that you'd like to enable.
$data = mysql_fetch_array($result);
+
#On the Profile Settings page, click Edit next to Main Website Profile Information.
$packageid = $data["packageid"];
+
#Change the E-Commerce Website radio button from No to Yes.
$result = select_query("tblproducts","name, type",array("id"=>$packageid));
 
$data = mysql_fetch_array($result);
 
$name = $data["name"];
 
$type = $data["type"];
 
$this->assign('name',$name);
 
$this->assign('type',$type);
 
$this->assign('packageid',$packageid);
 
{/php}
 
  
<script type="text/javascript">
+
Once you've done this, simply activate the Google Analytics module in WHMCS and enter your Analytics Tracking ID and optionally Root Domain (if you use multiple subdomains for your site) where requested.
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"));
+
Then the final step is to add the javascript for tracking page views to both your site and WHMCS client areaWHMCS makes this easy by defining a template tag {$google_analytics_html} which you just need to add where you want the tracking code output. We recommend placing this just before the closing body tag </body> in your active header.tpl or footer.tpl template files.
var pageTracker = _gat._getTracker("UA-XXXXX-X");
 
pageTracker._trackPageview();
 
pageTracker._addTrans( "{$orderid}", "", "{$amount}", "0", "0", "{$city}", "{$state}", "{$country}" );
 
pageTracker._addItem( "{$orderid}", "{$packageid}", "{$name}", "{$type}", "{$amount}","1" );
 
pageTracker._trackTrans();
 
</script></nowiki>
 

Revision as of 02:48, 2 September 2011

Google Analytics allows you to track how people find your site, how they navigate through it and how they become customers. You can see trends of pageviews, visits, bounce rate, conversion rate, geographical locations and much more.

And in WHMCS, we make it easy to use Google's service by providing an addon module which you can simply install & activate to automate the integration process.

Download/Install

To download the latest version of the module, please visit the Official Addon Listing page for it @ http://www.whmcs.com/members/communityaddons.php?action=viewmod&id=314

Once downloaded, simply unzip the file and upload the google_analytics folder within it to the /modules/addons/ directory of your WHMCS installation.

Setup

The first step of tracking e-commerce transactions with Google Analytics is to enable e-commerce reporting for your website's profile inside the Google Analytics panel:

  1. Sign in to your account.
  2. Click Edit next to the profile that you'd like to enable.
  3. On the Profile Settings page, click Edit next to Main Website Profile Information.
  4. Change the E-Commerce Website radio button from No to Yes.

Once you've done this, simply activate the Google Analytics module in WHMCS and enter your Analytics Tracking ID and optionally Root Domain (if you use multiple subdomains for your site) where requested.

Then the final step is to add the javascript for tracking page views to both your site and WHMCS client area. WHMCS makes this easy by defining a template tag {$google_analytics_html} which you just need to add where you want the tracking code output. We recommend placing this just before the closing body tag </body> in your active header.tpl or footer.tpl template files.