Skip to content
Tools to collect detailed usage analytics of Idyll articles.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Apr 9, 2019


Tools to collect detailed usage analytics of Idyll articles.


To install the analytics package, run the following in your Idyll project:

$ npm install --save idyll-analytics


This code is intended to be used as a custom runtime plugin for Idyll. To use it, you need to create a custom context file and import the analytics code there. See the idyll docs for more information on custom contexts.

This plugin relies on Firebase for data storage, and you'll need to have a Firebase database set up and credentials available in order to use it.

Creating a custom context file

Create a new file called context.js in your Idyll project:

const Analytics = require('./index');

// Fill out these credentials.
const firebaseConfig = {
  apiKey: "",
  authDomain: "",
  databaseURL: "",
  projectId: "",
  storageBucket: "",
  messagingSenderId: ""

module.exports = (context) => {
  const initialState =;

  // Update this with a relevant identifier for your post.
  const analytics = new Analytics('my-post-title', firebaseConfig);

  analytics.onLoad(() => {
    context.onUpdate((newState) => {

Configuring Idyll to use the custom context

In your package.json file, update the idyll option to use your newly created context:

  "idyll": {
    "context": "./context.js"
You can’t perform that action at this time.