Add Hardal analytics to a Gatsby website by loading the Hardal tracking script through gatsby-config.js. The plugin configures the website ID, script URL, automatic tracking, built-in events, and Do Not Track behavior.
You need a Gatsby site, a Hardal website ID, and a compatible Hardal tracker URL. Install the plugin, then add the configuration below to your Gatsby project.
npm install --save gatsby-plugin-hardal
# or
yarn add gatsby-plugin-hardal// In your gatsby-config.js
plugins: [
{
resolve: `gatsby-plugin-hardal`,
options: {
websiteId: "<PASTE_YOUR_WEBSITE_ID>",
srcUrl: "https://app.usehardal.com/hardal.js",
includeInDevelopment: true,
autoTrack: true,
builtInEvents: false, // get your built-in events like scroll, rage click, etc.
respectDoNotTrack: true,
eventModel: "web2"
}
}
];includeInDevelopment controls whether the script is included during development; production builds include it automatically. See the plugin source for the exact script attributes.
Maintained by Hardal.