Solved

Downloadlink clicked tracking

Posted on 2011-03-07
10
272 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

624 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