gatsby-plugin-hotjar
Advanced tools
Comparing version
@@ -10,3 +10,4 @@ 'use strict'; | ||
exports.onRenderBody = function (_ref, pluginOptions) { | ||
var setPostBodyComponents = _ref.setPostBodyComponents; | ||
var setPostBodyComponents = _ref.setPostBodyComponents, | ||
setHeadComponents = _ref.setHeadComponents; | ||
@@ -17,3 +18,5 @@ if (process.env.NODE_ENV === 'production' || pluginOptions.includeInDevelopment) { | ||
return setPostBodyComponents([_react2.default.createElement('script', { | ||
var addToHead = pluginOptions.addToHead || false; | ||
var script = [_react2.default.createElement('script', { | ||
key: 'gatsby-plugin-hotjar', | ||
@@ -23,3 +26,9 @@ dangerouslySetInnerHTML: { | ||
} | ||
})]); | ||
})]; | ||
if (addToHead) { | ||
return setHeadComponents(script); | ||
} else { | ||
return setPostBodyComponents(script); | ||
} | ||
} | ||
@@ -26,0 +35,0 @@ |
{ | ||
"name": "gatsby-plugin-hotjar", | ||
"version": "1.1.1", | ||
"version": "1.2.1", | ||
"description": "Gatsby plugin to add Hotjar analytics to your site.", | ||
@@ -20,14 +20,14 @@ "keywords": [ | ||
"watch": "babel -w src --out-dir . --ignore __tests__", | ||
"prepublish": "cross-env NODE_ENV=production npm run build" | ||
"prepare": "cross-env NODE_ENV=production npm run build" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"cross-env": "^5.0.5", | ||
"babel-preset-latest": "^6.24.1", | ||
"babel-preset-react": "^6.24.1", | ||
"babel-preset-stage-0": "^6.24.1" | ||
"babel-cli": "6.26.0", | ||
"cross-env": "5.0.5", | ||
"babel-preset-latest": "6.24.1", | ||
"babel-preset-react": "6.24.1", | ||
"babel-preset-stage-0": "6.24.1" | ||
}, | ||
"dependencies": { | ||
"babel-runtime": "^6.26.0" | ||
"babel-runtime": "6.26.0" | ||
} | ||
} |
@@ -17,12 +17,15 @@ # gatsby-plugin-hotjar | ||
// In your gatsby-config.js | ||
plugins: [ | ||
{ | ||
resolve: `gatsby-plugin-hotjar`, | ||
options: { | ||
includeInDevelopment: true, // optional parameter to include script in development | ||
id: YOUR_HOTJAR_ID, | ||
sv: YOUR_HOTJAR_SNIPPET_VERSION, | ||
module.exports = { | ||
plugins: [ | ||
{ | ||
resolve: "gatsby-plugin-hotjar", | ||
options: { | ||
includeInDevelopment: true, // optional parameter to include script in development | ||
addToHead: false, // optional parameter to append script to the head instead of the body | ||
id: YOUR_HOTJAR_ID, | ||
sv: YOUR_HOTJAR_SNIPPET_VERSION, | ||
}, | ||
}, | ||
}, | ||
]; | ||
], | ||
}; | ||
``` | ||
@@ -29,0 +32,0 @@ |
4252
50.04%6
20%26
36.84%39
8.33%Updated