diff --git a/README.md b/README.md index 6e8b37fe..2eaf5d31 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Or RDoc: If you prefer, you can skip the badge and use a transparent pixel. To do so, simply append `?pixel` to the image URL. There are also "flat" style variants available, which are available when appending `?flat` or `?flat-gif` to the image URL. And that's it, add the tracker image to the pages you want to track and then head to your Google Analytics account to see real-time and aggregated visit analytics for your projects! -You may also auto-calculate the tracking path based in the "referrer" information of the image. To activate this simple add `?useReferrer` to the image URL (or `&useReferrer` if you need to combine this with the `?pixel`, `?flat` or `?flat-gif` parameter). Although they are some odd browsers that don't always send the referrer, the amount of traffic coming from those browsers is usually not relevant at all. Of course that if you need to measure the traffic from those odd browsers you should not use this method. +You may also auto-calculate the tracking path based in the "referer" information of the image. To activate this simple add `?useReferrer` to the image URL (or `&useReferer` if you need to combine this with the `?pixel`, `?flat` or `?flat-gif` parameter). Although they are some odd browsers that don't always send the referer header, the amount of traffic coming from those browsers is usually not relevant at all. Of course that if you need to measure the traffic from those odd browsers you should not use this method. ### FAQ diff --git a/ga-beacon/ga-beacon.go b/ga-beacon/ga-beacon.go index 7cb9942f..aeb764cf 100644 --- a/ga-beacon/ga-beacon.go +++ b/ga-beacon/ga-beacon.go @@ -102,11 +102,13 @@ func handler(w http.ResponseWriter, r *http.Request) { return } - // activate referrer path if ?useReferrer is used and if referer exists - if _, ok := query["useReferrer"]; ok { + // activate referrer path if ?useReferer is used and if referer exists + if _, ok := query["useReferer"]; ok { if len(refOrg) != 0 { referer := strings.Replace(strings.Replace(refOrg, "http://", "", 1), "https://", "", 1); if len(referer) != 0 { + // if the useReferer is present and the referer information exists + // the path is ignored and the beacon referer information is used instead. params = strings.SplitN(strings.Trim(r.URL.Path, "/") + "/" + referer, "/", 2) } }