Skip to content

Commit

Permalink
small minor changes and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LRancez committed Apr 9, 2016
1 parent 8021a4e commit 3f69cf0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

This comment has been minimized.

Copy link
@JamieMason

JamieMason Nov 28, 2016

There are two spellings here: ?useReferrer and &useReferer.

I copied the useReferer version and do not get referral data in GA, so I think the value should be useReferrer? But I'm not completely sure as the spelling of the query in ga-beacon/ga-beacon.go was also changed in this commit.

Thanks.

/cc @igrigorik

This comment has been minimized.

Copy link
@igrigorik

igrigorik Nov 28, 2016

Owner

This comment has been minimized.

Copy link
@JamieMason

JamieMason Nov 28, 2016

Please forgive me if I'm mistaken, but I'm referring to the names of the query params of ga-beacon's own API rather than the name of the HTTP Header.

1) https://ga-beacon.appspot.com/UA-XXX/foo?flat&useReferer
2) https://ga-beacon.appspot.com/UA-XXX/foo?flat&useReferrer

I suppose what I'm asking is: For the image URL in my README, should I use URL 1, 2, or will either of them work? Currently I'm using URL 1 but that doesn't show referrer data in my google analytics.

This comment has been minimized.

Copy link
@igrigorik

igrigorik Nov 28, 2016

Owner

Doh, apologies.. misread your earlier comment. You should use one 'r': https://github.com/igrigorik/ga-beacon/blob/master/ga-beacon/ga-beacon.go#L106. Fixed in https://github.com/igrigorik/ga-beacon/blob/master/README.md.

Re, doesn't show up: note that not all requests cary a Referer header, see: https://www.w3.org/TR/referrer-policy/

This comment has been minimized.

Copy link
@JamieMason

JamieMason Nov 28, 2016

thanks a lot @igrigorik, appreciate the help.


### FAQ

Expand Down
6 changes: 4 additions & 2 deletions ga-beacon/ga-beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 3f69cf0

Please sign in to comment.