Skip to content

Instantly share code, notes, and snippets.

@ninnemana
Created February 3, 2015 15:14
Show Gist options
  • Select an option

  • Save ninnemana/387d8c7204214fa4557d to your computer and use it in GitHub Desktop.

Select an option

Save ninnemana/387d8c7204214fa4557d to your computer and use it in GitHub Desktop.
Example of routing analytics using the Measurement Protocol in golang
package main
import (
"net/http"
"net/url"
)
func main() {
vals := make(url.Values, 0)
vals.Add("v", "1")
vals.Add("tid", "UA-XXXXXX-1")
vals.Add("cid", "555")
vals.Add("t", "event")
vals.Add("ec", "Part")
vals.Add("ea", "GetPart")
vals.Add("el", "dataType=JSON&partID=11000")
vals.Add("ev", "200")
for i := 0; i < 100000; i++ {
if _, err := http.Get("http://www.google-analytics.com/collect?" + vals.Encode()); err != nil {
panic(err)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment