Solved

Downloadlink clicked tracking

Posted on 2011-03-07
10
266 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
 

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now