Solved

Downloadlink clicked tracking

Posted on 2011-03-07
10
267 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

910 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

22 Experts available now in Live!

Get 1:1 Help Now