Support » Plugin: Google Analytics for WordPress by MonsterInsights » Best way to provide download for compatibility

  • Hello,
    So I’m wondering what the best way of providing a download is for compatibility with this plugins tracking abilities.

    The method I usually use is to send the url to a PHP page which forces a header content-type of octet/stream to force it to download (otherwise the file just opens in the browser).

    Would this plugin track that as a download?
    How would you recommend doing it?


Viewing 2 replies - 1 through 2 (of 2 total)
  • If I was running on an Apache server I would create a rewrite rule to rewrite all requests for PDF files or other types of downloadable documents to the script.


    RewriteRule ^(.+\.pdf)$ /my-document-loader.php?file=$1

    Hi Hube – since making the original post, I have started using this in my htaccess file.
    Note to the less savvy: Obviously this is for mp3’s but it’s easy enough change to any file type you want, just change mp3 to whatever file extension you want e.g. pdf

    <FilesMatch "\.(?i:mp3)$">
    	ForceType application/octet-stream
    	Header set Content-Disposition attachment

    I haven’t yet tested it with this extension, but I see no reason why this wouldn’t be tracked as a download.


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Best way to provide download for compatibility’ is closed to new replies.