pypa / packaging.python.org

Python Packaging User Guide
http://packaging.python.org
1.45k stars 932 forks source link

Enable Plausible analytics for the hosted packaging user guide #1561

Closed ncoghlan closed 4 months ago

ncoghlan commented 5 months ago

Activity tracking was recently enabled on the docs.python.org site, and it shows that one of the most frequently visited pages is the one for venv: https://plausible.io/docs.python.org/

The detailed page for the Google referals provides more detail on the search terms used: https://plausible.io/docs.python.org/?filters=((is,page,(/3/library/venv.html)),(is,source,(Google)))

With the high 86% bounce rate, it would be very interesting to know whether folks are leaving the site entirely because their question has already been answered, or if they're following the cross-reference link to https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments

Since packaging.python.org is a peer subdomain of docs.python.org, enabling the data collection should just be a matter of adding in <script defer data-domain="docs.python.org" src="https://plausible.io/js/script.js"></script> as part of the Sphinx template when deploying to the main packaging.python.org environment.

The CPython docs use an environment variable to control whether or not to insert the analytics snippet (so it gets omitted in local builds of the packaging docs), and I think it would make sense to do the same thing for the packaging user guide (we could even use the same environment variable name: PYTHON_DOCS_ENABLE_ANALYTICS)

ncoghlan commented 5 months ago

Discourse thread: https://discuss.python.org/t/collecting-web-analytics-for-packaging-python-org/55961

willingc commented 5 months ago

Thanks @ncoghlan. This seems like a reasonable thing to do.

hugovk commented 5 months ago

I've added packaging.python.org to the Plausible account, the next step is for someone to add this snippet to some template file:

<script defer data-domain="packaging.python.org" src="https://plausible.io/js/script.js"></script>
ncoghlan commented 5 months ago

I thought the addition of the HTML snippet was going to be straightforward, but I had forgotten that since the user guide is currently using the Furo theme without any customisations, there isn't an existing HTML template in the repo that we can drop the extra snippet into the way there was for CPython.

@pradyunsg Any suggestions for a good way to do that, which won't risk running afoul of the compatibility concerns you raise in https://pradyunsg.me/furo/customisation/injecting/ ?

pradyunsg commented 5 months ago

Inject it in via https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_js_files in conf.py.

That blurb is there more for people to not generate work for me by needing me to support utterly bespoke setups with extensive customisation -- injecting a tracking JS script is a simple enough thing to do without needing custom templates and won't rely on details like class names etc in the markup.

ncoghlan commented 5 months ago

PR posted using html_js_files to do the injection. I ended up using RTD's standard environment variables to identify deployments specifically to packaging.python.org, so local builds, PR builds, and fork builds won't try to run the metrics collection code.

ncoghlan commented 4 months ago

The site has the JS snippet up and running. Once we get the backend config sorted out, the metrics will appear at https://plausible.io/packaging.python.org/

(Hugo is chatting to Plausible and the PSF Infrastructure team to try to work out what we did wrong in the service config)

hugovk commented 4 months ago

@ewdurbin Hi! I added packaging.python.org to Plausible but when I visit https://plausible.io/packaging.python.org/ I see:

This dashboard is locked because you don't have a valid subscription. Please subscribe to the appropriate tier with the link below to access the stats again.

I think this means it didn't get added to the proper PSF account, I guess it needs to be done by the primary owner.

I emailed Plausible last week to ask about it but they've not replied yet. However, I think if you visit https://plausible.io/packaging.python.org it will allow you to request an ownership transfer? Please could you try it?

Thanks!

ewdurbin commented 4 months ago

Hi @hugovk it will not allow me to request a transfer it says that the dashboard is locked.

Can you delete the site and allow me to create it?

ewdurbin commented 4 months ago

While here, a note that we're already at ~5M page views on docs.python.org of our 10M for the billing cycle (ending next week).

I'll reach out to plausible as well regarding what pricing options we have, but I'm worried adding packaging.python.org will over-run our plan.

hugovk commented 4 months ago

Can you delete the site and allow me to create it?

Deleted.

While here, a note that we're already at ~5M page views on docs.python.org of our 10M for the billing cycle (ending next week).

I'll reach out to plausible as well regarding what pricing options we have, but I'm worried adding packaging.python.org will over-run our plan.

Plausible also offered a discount for the 20M plan. I suggest we check in again near the end of the trial when we have some numbers for packaging.python.org and decide what to do.

ewdurbin commented 4 months ago

Site added. Invitation sent to @hugovk for Admin

hugovk commented 4 months ago

Thanks, accepted!

I was going to invite @ncoghlan but the account is limited to 3 team members unless we upgrade, and we already have some people for docs.python.org. Let's try again after the trial, the limit should be 10 then.

Anyway, I've made it public at https://plausible.io/packaging.python.org and visits are being counted 📈

ncoghlan commented 4 months ago

My availability is pretty erratic, so leaving me off the admin list is also fine (I'm not sure what Plausible admins have the ability to configure - the default views already seem pretty useful)

pradyunsg commented 4 months ago

I'd like to be on the admin list, if we have the capacity to add admins without excess cost for the parties involved.

hugovk commented 4 months ago

@pradyunsg I'll add you once the trial is over (assuming the limit is higher).