Solved

Downloadlink clicked tracking

Posted on 2011-03-07
10
268 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
  • 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Checkout Page Input Field not aligned 1 23
Cpanel file manager 8 25
Select case on click 3 16
Why will this INSERT statement not insert the date? 2 2
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

803 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