Giter Site home page Giter Site logo

plugin-ga's Introduction

Google Analytics tracking for GitBook

You can use install it via NPM:

$ npm install gitbook-plugin-ga

And use it for your book with in the book.json:

{
    "plugins": ["ga"]
}

You can set the Google Analytics tracking ID using the plugins configuration in the book.json:

{
    "plugins": ["ga"],
    "pluginsConfig": {
        "ga": {
            "token": "UA-XXXX-Y"
        }
    }
}

You can customize the tracker object by passing additional configuration options. You can either pass in auto, none or an object:

{
    "plugins": ["ga"],
    "pluginsConfig": {
        "ga": {
            "token": "UA-XXXX-Y",
            "configuration": {
                "cookieName": "new_cookie_name",
                "cookieDomain": "mynew.domain.com"
            }
        }
    }
}

For an overview of all available configuration parameters, please refer to the analytics.js field reference.

plugin-ga's People

Contributors

aarono avatar benglewis avatar k33g avatar samypesse avatar stevenrombauts avatar ty- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

plugin-ga's Issues

results do not actually show up in google analytics

After installing gitbook-plugin-ga, and building a static site, and deploying that to a domain, setting up a google analytics property for that site, and then browsing a few pages,
no hits gets recorded in the dashboard
In fact if you go to Admin --> Tracking Code --> Status Message, it says:
"Tracking Not Installed"

I think that the reason for this is because gitbook-plugin-ga loads the google analytics script from within a Javascript file;
instead of putting the script tag on every single page,
like it recommends.

FWIW, I have manually edited the static site (outside of gitbook) do do just that,
and hits started showing in the reports immediately.

Plugin not working

Hi,

for some reason (and even though I've created the correct book.json), the plugin does not work - i can find my tracking code in the script settings, but Google Tag Assistant is only showing the original script of gitbook.com

My book.json:
{
"plugins": ["ga"],
"pluginsConfig": {
"ga": {
"token": "UA-72539203-1"
}
}
}

My book: manual.blackpilot.com

I have a multi-language site, could that be an issue?

Cheers

Are you sure this works?

I have it installed locally and globally. My PATH is pointing to the dir where the lib is installed and ...

$ gitbook build --plugins=ga
error: unknown option `--plugins'

Disabling for local development

Is there a recommended system for disabling this plugin when running Gitbook locally? I only want to track analytics on the production/hosted version of my gitbook.

Thanks for the great plugin!

GA admin status "tracking not installed," but GA Plugin is working

This is a minor issue but thought it might be worth mentioning. After an hour of fiddling around, I finally got the GA plugin to report user data on my GitBook, which uses a custom domain. I tried several different settings, and even manually pasted the tracking code into the README.md file. Not sure what caused it to start working, but it finally did.

Oddly, the GA Admin > Property > Tracking Code status page still says "Tracking Not Installed," even though I am receiving GA data. See screenshot. Is this an issue with the GA plugin -- or not?

overview_-_google_analytics_and_google_analytics

How to install in a gitbook.com hosted book?

I enabled this plugin in gitbook.com plugin store but it doesn't work, having require in JavaScript:

require(["gitbook"], function(gitbook) {
    // Load analytics.js
    gitbook.events.bind("start", function(e, config) {
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

        var cfg = config.ga;
        ga('create', cfg.token, cfg.configuration);
    });

    // Notify pageview
    gitbook.events.bind("page.change", function() {
        ga('send', 'pageview', window.location.pathname+window.location.search);
    });
});

Please see docs.entriwise.com for concrete example.

How do I fix it?

gitbook fails to add local npm installed plugins

Following your documentation on a gitbook fails

npm install gitbook-plugin-ga
gitbook build ./ --plugins=ga
Starting build ...
Error: Error loading plugins: ga
    at Function.Plugin.fromList (/usr/local/lib/node_modules/gitbook/lib/generate/plugin.js:134:45)
    at BaseGenerator.loadPlugins (/usr/local/lib/node_modules/gitbook/lib/generate/generator.js:22:19)
    at Generator.loadPlugins (/usr/local/lib/node_modules/gitbook/lib/generate/site/index.js:50:48)
    at bound [as loadPlugins] (/usr/local/lib/node_modules/gitbook/node_modules/lodash/dist/lodash.js:729:21)
    at /usr/local/lib/node_modules/gitbook/lib/generate/index.js:81:26
    at _fulfilled (/usr/local/lib/node_modules/gitbook/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/gitbook/node_modules/q/q.js:816:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/gitbook/node_modules/q/q.js:749:13)
    at /usr/local/lib/node_modules/gitbook/node_modules/q/q.js:557:44
    at flush (/usr/local/lib/node_modules/gitbook/node_modules/q/q.js:108:17)

I use version 0.3.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.