Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

ContactSign Up
Community Plugin
View plugin on GitHub

Gatsby Plugin for Analytics

Gatsby plugin that combined logic of Google Analytics and Facebook Pixel in single plugin.

Installation

npm i @simpozio/gatsby-plugin-analytics

Usage

Install plugin package from npm and add plugin configuration to your gatsby-config.js file

/* gatsby-config.js */
module.exports = {
  plugins: [
    {
      resolve: '@simpozio/gatsby-plugin-analytics',
      options: {
        head: true,
        fbq: {
          pixelId: 'your Facebook pixel id',
          disablePushState: true,
          trackViewContent: false,
          trackPageView: false
        },
        gtag: {
          trackingIds: ['your Google Analytics id', 'your Google Ads id', 'your Marketing Platform id'],
          trackPageView: false,
        }
      }
    }
  ]
}

Options

  • head: boolean - if true include script tags into head, else add them to the body
  • fbq: object - configuration for Facebook Pixel, includes next properties:
    • pixelId: number - your Facebook Pixel ID
    • disablePushState: boolean - enable/disable PageView tracking on History updates
    • trackViewContent: boolean - enable/disable tracking of ViewContent event on every route update
    • trackPageView: boolean - enable/disable default PageView tracking
  • gtag: object - configuration for Google gtag.js, includes next properties:
    • trackingIds: string[] - array of tracking ID’s of Google Services fits pattern - [‘your Google Analytics id’, ‘your Google Ads id’, ‘your Marketing Platform id’]
    • trackPageView: boolean - enable/disable default PageView tracking

Development

See simpozio-frontend-common library

© 2023 Gatsby, Inc.