Google Analytics by Yoast
Best way to provide download for compatibility (3 posts)

  1. joshdd
    Posted 1 year ago #

    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?



  2. John Huebner
    Posted 1 year ago #

    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

  3. joshdd
    Posted 1 year ago #

    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.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Google Analytics by Yoast
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic