I have a page with a series of links to Greasemonkey userscripts. The userscripts have @updateURL
parameters set, so that when I upload a new version to the page people who have the script installed either have their version of it updated automatically or are asked if they want to upgrade.
This all works fine. I have Google analytics installed on the hosting page, so I can see how many hits the page gets, but what I would like to know is how many people are getting the updates.
The normal analytics won't work because they all rely on somebody clicking on a link, but Greasemonkey downloads the updated file without clicking on anything (or, as far as I can tell, triggering a page hit in analytics).
I'm assuming I need a server-side solution, but I have no idea what it would look like. Maybe all the above about GM is irrelevant, and the simple question is:
How can I track how many times a file is downloaded from my server (without relying on counting clicks on download links)?
[EDIT FOR FURTHER INFO]
@Brock Adams Thank you for the answer - it was very detailed and exactly what I was looking for. I wasn't aware of the separate meta.js
option, but reading a little into it I see that it's a good idea anyway as it means that only the meta.js
file has to be downloaded (as opposed to the entire user.js
file) when checking for updates. When I set this up, auto-updates were kind of new and there wasn't much documentation around about them.
I still can't find much, so I wonder if you could clarify. The metadata in the main user.js
file stays the same, just with a pointer to meta.js
in the @updateURL
and without the version number, ie:
// ==UserScript==
// @namespace http://namespace.com/userscripts
// @description some description.
// @downloadURL https://namespace.com/userscripts/example.user.js
// @updateURL https://namespace.com/userscripts/example.meta.js
// @include https://example.com/*
// @grant none
// ==/UserScript==
and then all example.meta.js
has to have is
// ==UserScript==
// @version 2.1
// ==/UserScript==
is that correct? thanks again.