0

Hi all,

I have been on this now for two weeks. Very much a neewbie.

Despite following Googles own instructions to the letter I just can't get the analytics cookie working on the following page:

<?php 
	
	$filename = {name};
	$filesize = filesize($filename); 
    $filetype = substr($filename, -3, 3); 

    switch($filetype) {   
        case "pdf": $mime="application/pdf"; break; 
        case "zip": $mime="application/zip"; break; 
        case "doc": $mime="application/msword"; break; 
        case "xls": $mime="application/vnd.ms-excel"; break; 
        case "ppt": $mime="application/vnd.ms-powerpoint"; break; 
        case "gif": $mime="image/gif"; break; 
        case "png": $mime="image/png"; break; 
        case "jpg": $mime="image/jpg"; break; 
        case "mp3": $mime="audio/mpeg"; break; 
        case "wav": $mime="audio/x-wav"; break; 
        case "mpg": 
        case "mpe": $mime="video/mpeg"; break; 
        case "mov": $mime="video/quicktime"; break; 
        case "avi": $mime="video/x-msvideo"; break; 

        default : $mime="application/octet-stream"; break; 
    } 

    header("Pragma: public"); 
    header("Expires: 0"); 
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
    header("Cache-Control: public"); 
    header("Content-Description: File Transfer"); 
    header("Content-Transfer-Encoding: binary"); 

    header("Content-Type: {$mime}"); 
    header("Content-Length: {$filesize}"); 
    header("Content-Disposition: attachment; filename=\"{$filename}\";"); 
     
    @readfile($filename); 

?>

<br /> 
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-1511577-4']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
<html>
<?php include ("header.php"); ?>
<body>
<?php include ("analyticsTracking.php"); ?>
</body>
</html>
3
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by EverWebby
0

If this code is for downloading a file, it would be easier to put the tracking on the link that triggers this download.

0

Thanks for your suggestion Pritaeas -

Apologies fro being dumb but I'm a little confused by your suggestion: "put the tracking on the link that triggers this download". This page itself is the link that triggers the download.

just to clarify, this page is automatically generated when the client uploads the current file and is automatically named after the file: i.e. "currentfile.MP3.php". When the user clicks this link no page is displayed just the download file dialogue pops up. This has been designed so that users do not need to have the MP3 automatically play in their media player.

So what file is "the link that triggers the download" - or have I missed your point.

0

Ah - I see - that's great - the only thing is that the link is sent via an email. Will this code be ok in an email?

0

Thanks again Pritaeas, just got back - your advice looks useful - now in the process of checking

0

Interesting tidbit about google analytics. I noticed that google has keyword tool called school that lets you see others competitive keyword terms, but this only seems to show these keywords if you are using the google analytics. So, its something to consider when you decide to implement the free analytics code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.