https://github.com/rossmeier/piwik-middleware
Provides a simple middleware for server-side piwik tracking
https://github.com/rossmeier/piwik-middleware
analytics go golang macaron middleware piwik tracking
Last synced: 3 months ago
JSON representation
Provides a simple middleware for server-side piwik tracking
- Host: GitHub
- URL: https://github.com/rossmeier/piwik-middleware
- Owner: rossmeier
- License: mit
- Created: 2017-10-25T16:43:27.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-01T18:49:33.000Z (about 8 years ago)
- Last Synced: 2025-06-10T20:25:40.839Z (7 months ago)
- Topics: analytics, go, golang, macaron, middleware, piwik, tracking
- Language: Go
- Homepage:
- Size: 23.4 KB
- Stars: 5
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# piwik-middleware
[](https://travis-ci.org/veecue/piwik-middleware)
[](https://godoc.org/github.com/veecue/piwik-middleware)
[](https://goreportcard.com/report/github.com/veecue/piwik-middleware)
Piwik is a middleware for [macaron](https://go-macaron.com) that tracks visits via [piwik](https://piwik.org)'s [HTTP Tracking API](https://developer.piwik.org/api-reference/tracking-api)
on the serverside without any visibility for the client.
## Installation
`go get -u github.com/veecue/piwik-middleware`
## Usage
```go
package main
import (
"github.com/veecue/piwik-middleware"
"gopkg.in/macaron.v1"
)
func main() {
m := macaron.Classic()
const piwikenabled = true // this can come from your config
if piwikenabled {
m.Use(piwik.Piwik(piwik.Options{
PiwikURL: "http://localhost/piwik",
Token: "56cee37c8e0df1b6be1ebc66aca6567b",
WebsiteID: "1",
}))
} else {
// provide fake params so that the website doesn't panic
m.Map(piwik.FakeTrackingParams())
}
m.Get("/", func() string {
return "Hi"
})
m.Get("/search", func(ctx *macaron.Context, tracker *piwik.TrackingParams) {
// inform piwik about the search without results
tracker.Search(ctx.Req.URL.Query().Get("q"), 0)
})
m.Run()
}
```
## Options
The middleware takes a variety of options:
```go
// Options configures the piwik middleware
type Options struct {
// The URL of your piwik installation (with our without /piwik.php)
PiwikURL string
// Ignore the Do not Track header that is sent by the browser. This is not recommended
IgnoreDoNotTrack bool
// The ID of the website in piwik
WebsiteID string
// The piwik API's access token
Token string
}
```
## Contributing
If you have found any bugs or want to propose a new feature, feel free to submit an issue or PR