Using @frontity/analytics

I’d like to add Google Analytics to my Frontity project to track the visits to the pages of my project and some other events.

I’ve seen there’s this package → https://github.com/frontity/frontity/tree/dev/packages/analytics

There are also this 2 Feature Discussion:

Why this package? Does it work? How do I use it? What is the right way of using this package in my projects?

In case it is an ongoing deployment (because of the feature discussion)… can you advance the new features and the way the new version is supossed to work?

Hi @juanma :wave:

I leave here a status update. Actually we have two packages currently in beta:

Both packages are working and can be used, although the API is going to change in the near future.

The way of using them is installing the package like any other Frontity package and add the settings to the frontity.settings.js file.

For the @frontity/google-analytics package:

// frontity.settings.js
export default {
  packages: [
    {
      name: "@frontity/google-analytics",
      state: {
        googleAnalytics: {
          trackingIds: ['UA-12345678-9']
        },
      },
    },
  ],
};

For the @frontity/google-tag-manager package:

// frontity.settings.js
export default {
  packages: [
    {
      name: "@frontity/google-tag-manager",
      state: {
        googleTagManager: {
          containerIds: ['GTM-BCDFGHJ']
        },
      },
    },
  ],
};

The settings are not going to change, just the way these package use the Analytics library that is the library allowing analytics packages to share the same API for sending pageviews and events.

We are going to change that API (there is an implementation proposal in the feature discussion) so, once we release the first stable version fro the Analytics library and adapt the analytics packages, anyone using the beta packages should update to the latest version.

5 Likes

I think we should rename the Google Tag Manager package.