Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

rossmeier/piwik-middleware

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

piwik-middleware

Build Status GoDoc Go Report Card

Piwik is a middleware for macaron that tracks visits via piwik's HTTP Tracking API on the serverside without any visibility for the client.

Installation

go get -u github.com/veecue/piwik-middleware

Usage

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:

// 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

About

Provides a simple middleware for server-side piwik tracking

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.