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>