Skip to content

Instantly share code, notes, and snippets.

@Boldewyn
Created January 9, 2014 15:34
Embed
What would you like to do?

Track deployments with Piwik's Annotation API

If you use analytics tools to monitor your website, a good metric for determining the effect of changes is the time of a deployment. Does the conversion rate really improve with the latest adjustments? Has the number of 404 errors decreased since we fixed that script?

Like other analytics products, Piwik allows you to annotate your data. Wouldn't it be great if all deployments were noted automatically? With the Annotation API it's actually quite simple.

In your deployment process, just add the following line to your script or post-receive hook and fill in the placeholders:

curl "http://YOUR_PIWIK_DOMAIN/?module=API&\
	method=Annotations.add&\
	idSite=YOUR_SITE_ID&\
	date=today&\
	note=Deployment&\
	&token_auth=YOUR_SECRET_API_TOKEN"

You can find your authentication token in your Piwik dashboard under the "API" link. Just make sure this script is put in a safe place and is not publicly accessible, as the token works like a password to your Piwik service.

It's also recommended to include the exact time of the deployment and the revision number in the note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment