Solved

Downloadlink clicked tracking

Posted on 2011-03-07
10
270 Views
Last Modified: 2012-05-11
Hi,

I would like to track the number of time a customer is downloading my application from the website.
Currently they just click on a link and the download starts, but this isn't pickedup by google analytics.
What would be a good approach to make tracking possible?

I thought of adding a page like:
"Thank you for downloading"
"If your download doesn't start automatically please click this link"

Open in new window


Can anybody supply me with some simple example on how to set this up correctly?
I prefer code in HTML and/or PHP.
0
Comment
Question by:Delphiwizard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 5

Expert Comment

by:palanee83
ID: 35066017
Whether user click on some PHP script to download (PHP script internally fetches the content of the downloaded file and sent to the browser) OR they click on the actual download file to download it.

If you have PHP script , you can track it easily .
0
 
LVL 5

Accepted Solution

by:
palanee83 earned 167 total points
ID: 35066073
more information about how to download the file using PHP,

http://www.finalwebsites.com/forums/topic/php-file-download

http://php.net/manual/en/function.header.php

If Google  analytic doesn't work, Then you can have your logic in your download script to track the number of time the file has downloaded.  Just log all the request which comes to this script. This will tell you the number of time the file has downloaded.  

 
0
 
LVL 3

Assisted Solution

by:pius_babbun
pius_babbun earned 166 total points
ID: 35066124
You can use database table to manage the count of the downloads. I have just created the count field in this sample code you can add user id and more fileds you want in this table .Hope this helps you.
//FOR EXAMPLE - DOWNLOADING PDF FILES
	$filename	= $_REQUEST['filename'];
	$filepath	= "foldername/".$filename;	
	$extenstion = explode(".",$filename);
 	$filesize = filesize($filepath);
 	if($extension == "pdf")
	{
		header("Content-length: $filesize");
		header("Content-type: application/pdf");
	}
  	header("Content-Disposition: attachment; filename=$filename");
  	$handle 		= @fopen($filepath, "r");
	$contents 		= @fread($handle, filesize($filepath));
 	fclose($handle);
 	echo $contents;
	
	
	########################## COUNTER CODE BEGIN ###########################################	
 	
	//UPDATE THE DOWNLOAD COUNTER TABLE	EACH TIME THE DOWNLOAD LINK IS CLICKED
 	//DATABASE CONNECTION
	$conn = mysql_connect('hostname','username','passwor');
	$db   = mysql_select_db('dbname',$conn); 
  	
	//CREATE COUNTER TABLE
	/*
		CREATE TABLE IF NOT EXISTS `tbl_download_counter` (
		  `id` int(11) NOT NULL,
		  `download` int(11) NOT NULL,
		  `updated_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
		  PRIMARY KEY  (`id`)
		)
	 */
	 
	 $Query  = " UPDATE `tbl_download_counter` A SET A.download = (download + 1)  , A.`updated_date` = NOW() WHERE A.`id` = 1;";
	 $Result = mysql_query($Query) or die("Query Error :".mysql_error());
 	 
	 ########################## COUNTER CODE END ###########################################

Open in new window

0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:Delphiwizard
ID: 35067115
Isn't there a solution possible without using a DB?
Just plain HTML so Google analytics can pick it up?
0
 
LVL 11

Expert Comment

by:mattibutt
ID: 35067138
It is possible via GA however the better option is php google doesn't reveal the ip address with the php and db you can tracl that
0
 

Author Comment

by:Delphiwizard
ID: 35067197
I don't realy need to IP.
I just want to know how many times the downloadlink is clicked.
0
 
LVL 11

Assisted Solution

by:mattibutt
mattibutt earned 167 total points
ID: 35067479
Have you looked a google intelligence beta which shows how many clicks in percentage
0
 

Author Comment

by:Delphiwizard
ID: 35068018
Yes, but that doesn't show this for downloadlinks.
0
 

Author Comment

by:Delphiwizard
ID: 35096620
Is there anybody who can show me a simple example in HTML/PHP without database?
One page where the download is started (link is clicked)
Second page "Thank you for downloading...etc." (see my initial question.
On the second page Google Analytics can be integrated.
0
 

Author Closing Comment

by:Delphiwizard
ID: 35238718
Thank you all
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question