I have decided to switch from using Google Analytics to Plausible analytics for my website. However, I am encountering an issue with adding the Plausible script to the head of my Nuxt JS document. I have created a custom plugin to handle this, but the Vue Meta api does not seem to allow for adding custom attributes to a script tag. Specifically, I need to include a custom attribute "data-domain" in the script and I am struggling to find a solution.
Below is my custom plugin file located at ~/plugins/plausible.js:
export default ({ app: { head, router, context } }, inject) => {
head.scripts.push({
src: "https://plausible.io/js/plausible.js",
async: true,
defer: true,
"data-domain": "jmcardle.co"
});
};
Here is the relevant section from my nuxt.config.js file:
plugins: [{
src: '~plugins/plausible.js',
mode: 'client'
}],
Any assistance would be greatly appreciated. Thank you!