@factor/plugin-server-analytics

1.8.28 • Public • Published

Factor Server Analytics

This plugin adds tracking of server activity via Google Analytics.

Install

npm add  @factor/plugin-server-analytics

Settings

// factor-settings.js
export default {
  serverAnalytics: {
    trackingId: "", // GA tracking ID - ua-xxxx-xx
    trackEndpointHits: true, // Send endpoint request events (track each endpoint request)
  },
}

Usage

Tracking endpoint requests

By default this plugin will track endpoint requests with the following:

  • event: 'endpointRequest'
  • action: the id of the endpoint
  • method: the method called

Triggering Custom Server Events

To send a custom event, all that you need to do is send a get/post request to the /__track_event__ endpoint.

The query parameters passed should event, action and/or label.

Example:

import axios from "axios"

axios.get("/__track_event__?event=myEvent&action=theAction&label=theLabel")

A Note On Traffic Filtering

Because server events are triggered from Node, they will show as "non-browser" traffic in analytics (no browser or language set). Keep this in mind when creating filters to screen out bot traffic, etc..

Package Sidebar

Install

npm i @factor/plugin-server-analytics

Weekly Downloads

1

Version

1.8.28

License

MIT

Unpacked Size

24.9 kB

Total Files

7

Last publish

Collaborators

  • raylopezaleman
  • arpowers