Showing results for 
Show  only  | Search instead for 
Did you mean: 
Former Employee

Tracking traffic to your client websites

I just had a discussion with a friend about tracking visits/visitors on client sites.  There are lots of options out there.  I'm curious what you all are using? What do like and dislike about the tools? Do you share the stats with your clients? 

Advocate VI

I install Google Analytics on just about everything I build. Most clients, I teach them how to log in and look at the data on their own, but some do ask me to summarize and/or pull reports occasionally. 

Of course many clients don't even look at the data (or more likely, just get busy and forget to look at it). Mostly, I care about installing it as soon as a new site is built, so that the data is there, should they either want it, or need it, or hire an SEO expert who wants to see it. Otherwise, if you suddenly decide you want the data, and don't have it -- you have to install the tracking code and wait to get a decent sample of data over time.

I rarely have to sell clients on adding Google Analytics -- it's free, it's easy to install, it works invisibly. It's not perfect, but it's available.

I know there are many other tools available, but many are not free. I think that for most of my clients (very small businesses, non-profits, etc.), they don't quite see the value of paying for the data. I'm not saying it isn't valuable, it could very well be worth paying for IF they would use the data. 

If others have a free alternative that they highly recommend, I'd be interested in hearing about it.

Former Employee

Thanks Lisa!  I agree Google Analytics is good for those reasons and can be pretty powerful if like you said people use it. Sometimes it's just hard to get the meaningful data back out of it.


What about everyone else?  What are you using?


Google has a lot more going on than just basic analytics.  Explore the Google Tag Manager and you can really start to get fine grained data about how people interact with your site.  You can add click handlers to buttons, controls and links, track transactions, impressions and conversions and do A/B testing on landing pages.  If you've got an eCommerce site, check out their advanced analytics that let you track not just people who land on your thank you page but which items they bought, quantities, total revenue, tax and shipping.


Your SEO guy will want analytics.  Your marketing guy will want Enhanced eCommerce.


Oh, and for Paypal transactions where you can't count on a customer hitting a thank you page, there's the Measurement Protocal API.  On your Paypal IPN page, add some server-side script that POSTs data to Google's server adding a transaction with all the above information on items, quantities and totals.

Keep on Coding!
Mark Cicchetti - There are 10 kinds of people... those who understand binary and those who don't.

+1 for Google Analytics...



Former Employee

@D3 - that's great stuff! Sounds like you're pretty familiar with GA.  


Any specific tips you can share with how you've used Tag Manager successfully? Or maybe some things you've done that didn't work so well?


The biggest issue I've seen with GA is tracking Paypal orders.  The problem lies in the payment flow.  With a credit card authorization, you get sent to a Thank You page where the normal tags work.


<script type="text/javascript"> 
    var _gaq = _gaq || []; 
  _gaq.push(['_setAccount', 'UA-XXXXXXX-1']); 
              "!---INVOICE---",            // order ID - required
              "yourstore",  // affiliation or store name
              "!---NO_FORMAT_TOTAL---",           // total - required
              "!---NO_FORMAT_TAX---",            // tax
              "!---NO_FORMAT_SHIPPING_TOTAL---",           // shipping
              "!---BILLCITY---",        // city
              "!---BILLSTATE---",      // state or province
              "!---BILLCOUNTRY---"              // country

// add item should be called for every item in the shopping cart 
// where your ecommerce engine loops through each item in the cart and 
 // prints out _addItem for each 
      "!---INVOICE---",           // order ID - necessary to associate item with transaction
      "!---SKU---",           // SKU/code - required
      "!---DESC---",        // product name
      "!---PRODUCT_CATEGORY_CODE---",   // category or variation
      "!---PRICE---",          // unit price - required
      "!---QTY---"               // quantity - required
  _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers 

Boom!  You're done.  In Google Analytics, on the left side click conversions and ecommerce to view your transactions and product performance.  Yay!

On the other hand, Paypal payment goes to Paypal where a person can either use a credit card or log into their account and pay with their Paypal balance.  Either way, they'll get to a page that tells them their payment is complete with a link that says "return to <your store>" that they may or may not click.  That data is lost unless you find another way.  Enter Google's Measurement Protocol.

Now Paypal is going to send your eCommerce software a notification (called IPN or Instant Payment Notification).  This happens server to server without human intervention.  This notification has all the information that would normally be posted to your "Thank You" page.

IPN scripts are tricky and the smallest mistake can break them.  I like to wait till they've done their thing and the cart software has populated the database.  I'll run a cron (a discussion unto itself) job every night to retrieve the orders filtered by payment type = "Paypal".  Something like:


$d = date('Ymd', strtotime('yesterday'));
echo('processing '.$d.'<br>');
$sql = "SELECT o.*, oi.*, si.* FROM `ORDER_BILL_INFO` as o LEFT JOIN ORDER_INFO as oi ON o.BillID = oi.OrderID LEFT JOIN ORDER_SHIP_INFO as si on o.BillID = si.SOrderID WHERE o.BillingMethod = 'PayPal' and `TimeValue` = '$d'";
$RS = mysql_query($sql);

I've used the * character here for brevity but it's always best to specify only the columns you actually use.  Makes queries way faster.

In a similar way, I'll get the items associated with the orders and the totals (tax, total, subtotal, weight etc.).

So now, I'll have an array of orders with an associated array of items and totals.  I loop through each order and call a function add2GoogleAnalytics($order, $items, $totals).  Here is the function:

function add2GoogleAnalytics($order, $items, $totals) {
	//	the basics. Set up the transaction
	$transaction = array(
	//	Now set up the items
	foreach ($items as $key=>$item) {
		$hit[$key]['v'] = 1;
		$hit[$key]['tid'] = 'UA-XXXXXXX-1';
		$hit[$key]['cid'] = 555;	// Anonymous user.
		$hit[$key]['t'] = 'item';
		$hit[$key]['ti'] = $order['InvoiceNumber']; //	Associate with the transaction
		$hit[$key]['ic'] = $item['sku'];
		$hit[$key]['in'] = $item['PR_Description'];
		$hit[$key]['iv'] = $item['PR_ProductCategory'];
		$hit[$key]['ip'] = $item['PR_UnitPrice'];
		$hit[$key]['iq'] = $item['qty'];
		$hit[$key]['cu'] = 'USD';
	//	Do the transaction first.  Google has to have a transaction to attach
	//	the items too.  Can't send it all at once :(
	$query = http_build_query($transaction);
	$curl_log = fopen('curl_errors.log', 'w');	// Just me talking to myself.
	$headers = array("Content-Type:application/x-www-form-urlencoded");
	$handle = curl_init();
	curl_setopt($handle, CURLOPT_URL, '');
	curl_setopt($handle, CURLOPT_POST, count($hit));
	curl_setopt($handle, CURLOPT_POSTFIELDS, $query);
	curl_setopt($handle, CURLOPT_HEADER, true);
	curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($handle, CURLOPT_STDERR, $curl_log);
	curl_setopt($handle, CURLOPT_VERBOSE, true);
	$result = curl_exec($handle);
	foreach ($hit as $key=>$val) {
		$query = http_build_query($hit[$key]);
		$handle = NULL;
		$curl_log = fopen('curl_errors.log', 'w');
		$headers = array("Content-Type:application/x-www-form-urlencoded");
		$handle = curl_init();
		curl_setopt($handle, CURLOPT_URL, '');
		curl_setopt($handle, CURLOPT_POST, count($hit[$key]));
		curl_setopt($handle, CURLOPT_POSTFIELDS, $query);
		curl_setopt($handle, CURLOPT_HEADER, true);
		curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($handle, CURLOPT_STDERR, $curl_log);
		curl_setopt($handle, CURLOPT_VERBOSE, true);
		$result = curl_exec($handle);

Now when you check your analytics, you'll have a true representation of the products you've sold and the revenue generated.  Even better, you can filter by the landing page paypal-thank-you and see things like what kind of products your Paypal customers like and what percentage of your total sales went through Paypal.  Remind yourself why you bothered to support Paypal in the first place!

Keep on Coding!
Mark Cicchetti - There are 10 kinds of people... those who understand binary and those who don't.

hi, could you please help me out for the link counting? I made a website (I) by website builder, and in one page for example, page A, there are 3 buttons which link to other website (II) pages (B), which not belong to my site(I), the 3 buttons are link for different shopping pages. I gonna counting the clicks for the buttons by google analytics, but can not add any tracking code into the button Source Code, even can not see the button Source Code. so how can I do?  Thanks in advance!! Smiley Happy

Very basic question as I'm just starting to use Google Analytics: does each website I have need it's own goodly analytics Tracking ID?

Diva, so let's assume you're talking to an absolute imbecile (because it's entirely likely that you are), who is not satisfied with the GoDaddy "views" counter and wants to be able to better track which pages on his site are viewed, how long they're viewed, what time of day they're viewed, etc.


If said imbecile, who looks a lot like I do, uses the standard (which I believe is now the "old version") GoDaddy website builder, and wants to put the google analytics tool on every page and be able to use it, how would he go about it? 


And to cut to the chase, is there someone (maybe in this community) who can set all that up for a fee, since I'm (sorry - he's) not interested in learning all this computer mumbojumbo?


Thanks in advance for any help you can give me (him)!  😉

Advocate II

Yep, just adding another +1 to google analytics.


I always install it on whatever I build. You never know when a client might want to start some SEO, and having that data ALREADY there is priceless.

CEO of Antbuilt, LLC

If I have multiple views in my Google Analytics account, how do I make sure the right one is displayed on the Go Daddy management dashboard for WordPress? Thanks in advance!

I’ve been using Google Analytics for sometimes now and I recently just started using SEMrush and SEOCentro. They are 2 of the free tools I use for my local SEO Clients and they are pretty accurate!

Best regards, Anna Cozzy