Forums

[Plugin: Google Analytics for WordPress] downloads tracking doesn't work right with non-www domain (4 posts)

  1. btmorex
    Member
    Posted 4 years ago #

    Tracking of downloads isn't working right for non-www domains (i.e. blog.example.com). Technically, it actually works, but the tracked url looks bad ("/downloadsblog./path/to/file"). This is because of line 475 of googleanalytics.php:

    $file = str_replace('www.',"",$file);

    I fixed it locally by changing "www." to "blog.", but obviously there's a general way to do this. Just thought I'd report it.

  2. blogher8
    Member
    Posted 4 years ago #

    So if I am not using www. in my URLs, how do I fix this?
    Do I just replace line 475 with what you have above?
    Thanks!

  3. btmorex
    Member
    Posted 4 years ago #

    It depends on your domain. If your domain is blog.example.com

    change:
    $file = str_replace('www.',"",$file);
    to:
    $file = str_replace('blog.',"",$file);

    If you're just using example.com, I don't think you need to do anything.

  4. Joost de Valk
    Member
    Posted 4 years ago #

    Hmm I'll have another look at this, seems like something I should be fixing ;) (or getting rid of in the first place, why not leave the www in there? :) )

Topic Closed

This topic has been closed to new replies.

About this Topic