diff --git a/docs/userGuide/plugins/googleAnalytics.mbdf b/docs/userGuide/plugins/googleAnalytics.mbdf new file mode 100644 index 0000000000..a6da8457ed --- /dev/null +++ b/docs/userGuide/plugins/googleAnalytics.mbdf @@ -0,0 +1,24 @@ +#### `Google Analytics`: Enhancing site with Google Analytics + +This plugin allows your web pages to be enhanced with [google analytics](https://analytics.google.com/analytics/web/#/) to track, analyse and improve your content. + +To enable it, add `googleAnalytics` to your site's plugins, and add the trackingID parameter via the `pluginsContext`. + +Name | Type | Default | Description +---- | ---- | ------- | ------ +trackingID | `String` || Tracking ID provided by Google. Follow this [guide](https://support.google.com/analytics/answer/1008080) to get your Tracking ID. + +```js +site.json +{ + ... + "plugins": [ + "googleAnalytics" + ], + "pluginsContext": { + "googleAnalytics": { + "trackingID": "YOUR-TRACKING-ID", // replace with your google analytics tracking id. + } + } +} +``` diff --git a/docs/userGuide/usingPlugins.md b/docs/userGuide/usingPlugins.md index 722612bdce..e306a8239c 100644 --- a/docs/userGuide/usingPlugins.md +++ b/docs/userGuide/usingPlugins.md @@ -171,8 +171,9 @@ Disabling the `anchors` plugin: MarkBind has a set of built-in plugins that can be used immediately without installation. - + + {% from "njk/common.njk" import previous_next %} {{ previous_next('usingHtmlJavaScriptCss', 'tweakingThePageStructure') }} diff --git a/src/plugins/googleAnalytics.js b/src/plugins/googleAnalytics.js new file mode 100644 index 0000000000..8f1bd5094d --- /dev/null +++ b/src/plugins/googleAnalytics.js @@ -0,0 +1,17 @@ +function getGoogleAnalyticsTrackingCode(pluginContext) { + return ` + + + `; +} + +module.exports = { + // eslint-disable-next-line no-unused-vars + getScripts: (content, pluginContext, frontMatter, utils) => getGoogleAnalyticsTrackingCode(pluginContext), +}; diff --git a/test/functional/test_site/expected/bugs/index.html b/test/functional/test_site/expected/bugs/index.html index abdccb135d..c8f0ceb0ba 100644 --- a/test/functional/test_site/expected/bugs/index.html +++ b/test/functional/test_site/expected/bugs/index.html @@ -107,6 +107,19 @@