Giter Club home page Giter Club logo

blacklight_google_analytics's Introduction

Blacklight Google Analytics

A gem plugin which adds support for Google Analytics and event tracking to a Blacklight Rails application.

Installation

  1. Install Blacklight using the Quickstart guide.
  2. Add gem 'blacklight_google_analytics' to your Gemfile
  3. Run the generator: rails g blacklight_google_analytics. This adds an initializer (see next step) and adds a couple lines to app/assets/javascripts/application.js.
  4. Edit config/initializers/blacklight_google_analytics.rb to include your own Google Web id. You will need a Google Analytics account and profile. You will not need to copy in the async snippet. You will need to verify your profile.

Usage

Google Analytics tracking code is only turned on in production. Both page tracking and Blacklight-specific event tracking is turned on.

In development Google Analytics tracking is turned off. Tracking parameters are sent to the browser's console to allow you to see what parameters will be sent to Google Analytics for various actions.

Here's an example of event tracking. This is the output to the browser console when clicking on the Format facet, selecting the "Book" facet value, and then removing it:

["facets", "collapse_expand", "Format"]
["facets", "Format", "Book"]
["facets", "Format", "[remove]"]

These parameters are the category, action, and label according to the Google Analytics event tracking documentation. This event tracking information shows up in Google Analytics under Content > Events.

Customizing Blacklight for event tracking

You can add other links (e.g. a elements) to the page and they will be tracked automatically. If you give your link an id attribute, that will be used for the category. Otherwise, the id of the first parent element with an id attribute will be used as the category.

You may also add your own jQuery click handlers to add more event tracking. Look at the current handlers to see how to set up a tracking event and enable console.log in development.

Author

Jason Ronallo

Based on code from Brian Cray.

Copyright

Copyright © 2012 North Carolina State University. See MIT-LICENSE for details.

blacklight_google_analytics's People

Contributors

jronallo avatar

Watchers

Steven Anderson avatar James Cloos avatar  avatar Eben English avatar  avatar

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.