I used microanalytics.io for one book. It was pretty simple.
First, I put this in the _output.yml in the bookdown::gitbook: section...
includes:
in_header: files/html/in_header.html
Then I put the one-line microanalytics.io script in that in_header.html file. That's all it took.