Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add Google Analytics tracking. #6601

Closed
wants to merge 0 commits into from

Conversation

phillipj
Copy link
Member

@phillipj phillipj commented May 5, 2016

Checklist
  • tests and code linting passes
  • a test and/or benchmark is included
  • documentation is changed or added
  • the commit message follows commit guidelines
Affected core subsystem(s)

tools, doc

Description of change

Original changes has been discarded after discussions below.

This adds Google Analytics tracking to the bottom of all doc pages if we're building for Release make is run with DOCS_ANALYTICS variable present.

Any thoughts about this so far? Would you consider using build type like this sufficient to avoid tracking locally or other scenarios when tracking isn't wanted?

Refs nodejs/nodejs.org#709

/cc @nodejs/documentation

@phillipj phillipj added the doc Issues and PRs related to the documentations. label May 5, 2016
@@ -107,6 +120,10 @@ function render(lexed, filename, template, cb) {
});
}

function gaScriptContent() {
return fs.readFileSync(gaScriptPath).toString();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allowed my self to use Sync here as this is a build script, where doing async doesn't do too much for performance, other than increasing code complexity.

@addaleax addaleax added the tools Issues and PRs related to the tools directory. label May 5, 2016
@Fishrock123
Copy link
Contributor

The build is release by default... I don't really want this in local docs tbh

@phillipj
Copy link
Member Author

phillipj commented May 5, 2016

@Fishrock123 yeah, although this provides a way to opt-out of tracking, it's not ideal as Release is the default...

In a perfect world the tracking script would only be included when actually cutting new releases. I don't have access to the release build jobs so I haven't been able to see what exactly is run when building new versions - is there anything unique about those builds we could pick up automatically?

@jasnell
Copy link
Member

jasnell commented May 6, 2016

A flag could be added to configure to selectively enable this and that flag could be switched on in the release CI.

@Fishrock123
Copy link
Contributor

Fishrock123 commented May 6, 2016

I'd like thoughts from @nodejs/build

@rvagg
Copy link
Member

rvagg commented May 10, 2016

Here's my thoughts on where this needs to go:

  • we use the doc-upload target for building docs for nodejs.org, we're going to need to rejig that a bit because it depends on tar to get the docs to build so I suggest we make it depend on docs and have it do what tar does on top of that
  • use a make variable rather than build type to indicate this, so it's only ever done by CI and people who have a clue about how to turn it on. I suggest DOCS_ANALYTICS and maybe pass in the GA # via that but leave it blank by default so that when the build script get the arg (--analytics?) and it's empty it simply leaves it out.
  • the rest of the GA stuff can be included in the script, hard-wired, no need to pull it in from a separate file IMO, we can leave the code configurable and that can come via Jenkins, the rest can be hard-wired and appear if a code is supplied.
  • we have to make sure that the GA stuff doesn't appear inside the docs in the tarball while we're doing all of this

@phillipj
Copy link
Member Author

Thanks @rvagg, a lot of good tips I wasn't aware of there. I'll look into using a make variable instead.

@phillipj phillipj force-pushed the ga-docs-tracking branch 3 times, most recently from 8044926 to dc3e6ca Compare May 16, 2016 21:58
@phillipj
Copy link
Member Author

@rvagg PTAL now.

Couldn't see any reason doc-upload should depend on tar, so I simply changed it to be dependant on doc directly.

@phillipj phillipj force-pushed the ga-docs-tracking branch 2 times, most recently from 27e1a70 to 005cf5b Compare May 16, 2016 22:07
@@ -45,5 +45,6 @@
<script src="assets/sh_main.js"></script>
<script src="assets/sh_javascript.min.js"></script>
<script>highlight(undefined, undefined, 'pre');</script>
__TRACKING__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we perhaps comment this? <!-- __TRACKING__ --> -- that way we don't have to process any files if tracking is disabled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbergstroem it gets replaced w/empty string when tracking is disabled, which is default, so it shouldn't be needed to enclose in comments?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah was just suggesting we could avoid it altogether (replacing with empty) by making it a html comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on this. Why waste cpu cycles if we don't have to?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbergstroem sorry this slipped. I just pushed an update using a comment as you've suggested, PTAL.

@ChALkeR
Copy link
Member

ChALkeR commented May 18, 2016

Personally, I don't like the idea of including GA to the docs.
My opinion here is that if we really need to track how users use the docs, it should be done with a solution that is:

  1. Self-hosted.
  2. Respects DNT setting.

Piwik looks as a possible solution to me (judging only by description, I have not tested it).
Also I would prefer all the depersonalized data to be either publically accessible, or accessible to everyone on the org.

I don't want to block GA though if others agree that we need it, so that's a -0. /cc @nodejs/ctc

@bnoordhuis
Copy link
Member

I second what @ChALkeR said. The motivation in nodejs/nodejs.org#709 is knowing what parts of the documentation are visited more. It should be fairly straightforward to pull that information from the server logs, right?

@saghul
Copy link
Member

saghul commented May 19, 2016

Agreed with @ChALkeR. I use Piwik and it gets the job done. In case it helps, here is a screenshot from my own blog's stats: https://www.dropbox.com/s/cj7vnjbzn70gp8n/Screenshot%202016-05-19%2017.24.32.png?dl=0

@phillipj
Copy link
Member Author

@mikeal as you initially tried to add GA tracking, what's your thoughts on using Piwik instead?

@eljefedelrodeodeljefe
Copy link
Contributor

I have some points.

  • GA can be anonymized to some extent.
  • having two tracking systems is not unusual
  • tracking on the server manually is not a road we want to do down.


  • No matter GA or Piwik, having the dataset open without any or loose constraints opens up alls sorts of legal problems I assume. Using email addresses of just some people, who then pass down aggregated data is likely better. Maybe we could also use APIs for that.
  • I haven't used Piwik yet, but a grew fond of GA in mobile development contexts, since it allows really nice screenflow analytics, which I could reproduce hardly with other tracking solutions out-of-the-box


  • Currently we use a lot of JavaScript on page load already and load every page separately(, right?)
  • I am refactoring the doctool ATM and would integrate that rather after it. Since I wanted to look at more elegant ways, maybe templating.

So I am rather for deferring this to some later point and rather for GA (and additional others.)

@mikeal
Copy link
Contributor

mikeal commented May 25, 2016

We are using Google Analytics in several other places already and it would not be ideal to use something else for this as it makes things far more difficult. For instance, if we want to know the number of unique users across the website including the API docs this would make that impossible.

@ChALkeR
Copy link
Member

ChALkeR commented May 27, 2016

@eljefedelrodeodeljefe

GA can be anonymized to some extent.

I don't think so, it will still store and use unanonymized data.

No matter GA or Piwik, having the dataset open without any or loose constraints opens up alls sorts of legal problems I assume.

Could you elaborate? I was speaking only about anonymized data only. I'm not sure how does sharing the data with a third party not open similar issues then.

Using email addresses of just some people, who then pass down aggregated data is likely better. Maybe we could also use APIs for that.

That might be significantly more complex.

@mikeal

We are using Google Analytics in several other places already

I expect docs to be significantly more visited than any other places, so for anyone who views third-party unanonymized tracking as being harmful/unacceptable, including GA to the docs will make the situation considerably worse. /cc @nodejs/inclusivity, btw.

and it would not be ideal to use something else for this as it makes things far more difficult. For instance, if we want to know the number of unique users across the website including the API docs this would make that impossible.

Perhaps we should to add self-hosted tracking everywhere where GA is currently used, then? It should not harm to use them together for a time, I suppose.

@phillipj phillipj force-pushed the ga-docs-tracking branch 2 times, most recently from 356224b to 34bf996 Compare May 30, 2016 20:26
@phillipj
Copy link
Member Author

Rebased on top of master. As it doesn't seem to be consensus about using GA for docs tracking, should this be scheduled for the next CTC-meeting?

/cc @nodejs/ctc

@rvagg
Copy link
Member

rvagg commented May 31, 2016

It should be fairly straightforward to pull that information from the server logs, right?

No, CloudFlare serves the majority of our doc requests. Although, we do apparently have a path to getting full logs from CF (it's an Enterprise feature but we've discussed it with them already). Log processing is pretty far from optimal for what's being asked for here.

Those who are concerned about being tracked are probably already blocking GA, either explicitly or with blocking tools (I have two of them installed in my current browser!). I'm not a huge fan of giving more data to Google about the entire world but weighing that against the useful information that the docs WG could glean from this puts me well into the +1 for this.

Also, in case anyone's reading this and misinterprets: this is only enabling it for nodejs.org, not self-hosted or even in the tarball we ship.

Someone in @nodejs/build, maybe me, will need to confirm that the Makefile changes are going to be OK with our workflow before this can land.

@ChALkeR
Copy link
Member

ChALkeR commented May 31, 2016

@rvagg

the useful information that the docs WG could glean from this

Have you considered self-hosted tracking? Why is GA viewed as the only option to achieve that here?

@phillipj
Copy link
Member Author

Landed in 01b90ee

@phillipj
Copy link
Member Author

FYI / later reference: while merging this, I read through the COLLABORATOR_GUIDE.md and wanted to try the trick mentioned there, getting the PR status "merged" rather than "closed" by running git push --force-with-lease origin master:ga-docs-tracking.

That didn't work as expected. (1) Status was shown as "Closed" and (2) the UI shows this PR has 0 file changes. Not getting the "merged" status doesn't matter, but 0 file changes are really misleading tho!

targos pushed a commit that referenced this pull request Jan 28, 2017
Adds Google Analytics tracking script to all doc pages when
`DOCS_ANALYTICS` is set when running `make`:

```bash
$ DOCS_ANALYTICS=<GOOGLE ANALYTICS ID> make
```

By default (when `DOCS_ANALYTICS` is not set), no tracking scripts are
included.

It respects "Do Not Track" settings end users might have in their
browser.

Also changes make target `doc-upload` from depending on the
`$(TARBALL)` target, to only depend on `doc` directly.

PR-URL: #6601
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@gibfahn
Copy link
Member

gibfahn commented Jan 28, 2017

@phillipj did you push to nodejs/master before you pushed to phillipj/ga-docs-tracking? The PR only counts as merged if the head of your fork branch has the same SHA as the commit you push to master, so if you change the commit message then push to master, Github will say there are 0 changes, because only the commit messages (and hashes) have changed.

If you force push to your branch before updating node/master, that should work.

@phillipj
Copy link
Member Author

phillipj commented Jan 28, 2017 via email

@italoacasas italoacasas mentioned this pull request Jan 29, 2017
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 30, 2017
Adds Google Analytics tracking script to all doc pages when
`DOCS_ANALYTICS` is set when running `make`:

```bash
$ DOCS_ANALYTICS=<GOOGLE ANALYTICS ID> make
```

By default (when `DOCS_ANALYTICS` is not set), no tracking scripts are
included.

It respects "Do Not Track" settings end users might have in their
browser.

Also changes make target `doc-upload` from depending on the
`$(TARBALL)` target, to only depend on `doc` directly.

PR-URL: nodejs#6601
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 30, 2017
Adds Google Analytics tracking script to all doc pages when
`DOCS_ANALYTICS` is set when running `make`:

```bash
$ DOCS_ANALYTICS=<GOOGLE ANALYTICS ID> make
```

By default (when `DOCS_ANALYTICS` is not set), no tracking scripts are
included.

It respects "Do Not Track" settings end users might have in their
browser.

Also changes make target `doc-upload` from depending on the
`$(TARBALL)` target, to only depend on `doc` directly.

PR-URL: nodejs#6601
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
jasnell pushed a commit that referenced this pull request Mar 8, 2017
Adds Google Analytics tracking script to all doc pages when
`DOCS_ANALYTICS` is set when running `make`:

```bash
$ DOCS_ANALYTICS=<GOOGLE ANALYTICS ID> make
```

By default (when `DOCS_ANALYTICS` is not set), no tracking scripts are
included.

It respects "Do Not Track" settings end users might have in their
browser.

Also changes make target `doc-upload` from depending on the
`$(TARBALL)` target, to only depend on `doc` directly.

PR-URL: #6601
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
jasnell pushed a commit that referenced this pull request Mar 8, 2017
Adds Google Analytics tracking script to all doc pages when
`DOCS_ANALYTICS` is set when running `make`:

```bash
$ DOCS_ANALYTICS=<GOOGLE ANALYTICS ID> make
```

By default (when `DOCS_ANALYTICS` is not set), no tracking scripts are
included.

It respects "Do Not Track" settings end users might have in their
browser.

Also changes make target `doc-upload` from depending on the
`$(TARBALL)` target, to only depend on `doc` directly.

PR-URL: #6601
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
MylesBorins pushed a commit that referenced this pull request Mar 9, 2017
Adds Google Analytics tracking script to all doc pages when
`DOCS_ANALYTICS` is set when running `make`:

```bash
$ DOCS_ANALYTICS=<GOOGLE ANALYTICS ID> make
```

By default (when `DOCS_ANALYTICS` is not set), no tracking scripts are
included.

It respects "Do Not Track" settings end users might have in their
browser.

Also changes make target `doc-upload` from depending on the
`$(TARBALL)` target, to only depend on `doc` directly.

PR-URL: #6601
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Mar 9, 2017
MylesBorins pushed a commit that referenced this pull request Mar 9, 2017
Adds Google Analytics tracking script to all doc pages when
`DOCS_ANALYTICS` is set when running `make`:

```bash
$ DOCS_ANALYTICS=<GOOGLE ANALYTICS ID> make
```

By default (when `DOCS_ANALYTICS` is not set), no tracking scripts are
included.

It respects "Do Not Track" settings end users might have in their
browser.

Also changes make target `doc-upload` from depending on the
`$(TARBALL)` target, to only depend on `doc` directly.

PR-URL: #6601
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Mar 9, 2017
@ChALkeR
Copy link
Member

ChALkeR commented Jul 5, 2017

@phillipj @mikeal @chrisdickinson

Several months have passed with this landed. What information were we able to collect and how exactly is can we use it to improve things?

@phillipj
Copy link
Member Author

phillipj commented Jul 6, 2017

@ChALkeR thanks for following up 👍

Although this was merged a long time ago, it was activated a couple of weeks ago: nodejs/nodejs.org#1268 (comment). By checking the docs deployed to production, v8.1.3 docs looks like the first set of docs that has GA tracking enabled.

In other words I think it's a little early to answer your question about what the stats collected has provided of actual value yet.

Maybe @feross has some future plans?

@ChALkeR
Copy link
Member

ChALkeR commented Aug 30, 2018

Any updates?

bnoordhuis added a commit to bnoordhuis/io.js that referenced this pull request Sep 25, 2018
The Google Analytics tracking wasn't wholly uncontroversial and hasn't
been used in practice. Remove it.

Refs: nodejs#6601
Fixes: nodejs#22652
danbev pushed a commit that referenced this pull request Oct 4, 2018
The Google Analytics tracking wasn't wholly uncontroversial and hasn't
been used in practice. Remove it.

PR-URL: #23083
Fixes: #22652
Refs: #6601
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
targos pushed a commit that referenced this pull request Oct 4, 2018
The Google Analytics tracking wasn't wholly uncontroversial and hasn't
been used in practice. Remove it.

PR-URL: #23083
Fixes: #22652
Refs: #6601
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
jasnell pushed a commit that referenced this pull request Oct 17, 2018
The Google Analytics tracking wasn't wholly uncontroversial and hasn't
been used in practice. Remove it.

PR-URL: #23083
Fixes: #22652
Refs: #6601
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.