npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-cli-google-analytics

v1.5.0

Published

Ember CLI addon that adds the Google Analytics tracking code

Downloads

691

Readme

ember-cli-google-analytics

Plugin for ember-cli that injects Google Analytics tracking code into HTML content.

Installation

This plugin requires ember-cli version >= 0.0.47

To install simply run:

npm install --save-dev ember-cli-google-analytics

Warning: Content Security Policy

This plugin is intended to add Google Analytics tracking as an inline script. The ember-cli-content-security-policy addon that is included with ember-cli will prevent the execution of inline scripts.

A future version of this plugin is planned to add the tracking code as an additional JS file (much like ember-cli-inject-live-reload), but until then this plugin will not function out of the box with CSP installed.

Usage

Once configured, the Google Analytics tracking code will be injected into your index.html file. A mixin is provided for simple page view tracking inside of your Ember application. To use it, include it inside your app/router.js file:

import Ember from 'ember';
import config from './config/environment';
import googlePageview from './mixins/google-pageview';

var Router = Ember.Router.extend(googlePageview, {
  location: config.locationType
});

Router.map(function() {
  ...
});

export default Router;

Configuration

This plugin uses the Ember CLI project's configuration as defined in config/environment.js.

The tracking code will appear only if ENV.googleAnalytics.webPropertyId is defined. For instance, to enable the tracking code in only the production environment:

if (environment === 'production') {
  ENV.googleAnalytics = {
    webPropertyId: 'UA-XXXX-Y'
  };
}

Configuration Parameters

ga.js and analytics.js

  • webPropertyId (Default: null): the Web Property ID for the Google Web Property you wish to track.
  • tracker (Default: analytics.js): The Google Tracker to use, can be either analytics.js or ga.js.
  • globalVariable (Default: ga): the global variable to use for the Google Analytics tracker object. This is ignored when the tracker is ga.js.
  • displayFeatures (Default: false): enables Display Advertising tracking code.

analytics.js only

  • cookieDomain (Default: null): the domain to set the tracking cookies on. Can be a null, the domain to use for cookies, or 'none'.
  • cookieName (Default: null): the name of the cookie to set and use.
  • cookieExpires (Default: null): the expiration, in seconds, of the cookie.

If none of the cookie settings are set (they are left nullish) then 'auto' will be used for the cookie settings. Otherwise the JSON of only the settings set will be passed to the ga() function.

Running Tests

  • git clone [email protected]:pgrippi/ember-cli-google-analytics.git
  • npm install
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.