Open eljass opened 3 years ago
@eljass I would appreciate it if you could also add tests for these changes.
@farzadso I would but I don't really know how to test other libraries such as $gtm or global variables such as ga()
or dataLayer
with jest
It occurs to me that this is not probably necessary as the user could write a plugin which handles sending experiment with preferred way? So should we just introduce an option to disable ga()
event from firing on load?
Docs could then explain how to send a preferred event from the plugin.
For example GTM module would be
// plugins/google-optimize.js
export default function ({ $exp, $gtm }) {
const exp = experiment.experimentID + '.' + experiment.$variantIndexes.join('-')
$gtm.push({ exp })
}
// nuxt.conifg.js
export default {
...
googleOptimize: {
experimentsDir: '~/experiments',
maxAge: 60 * 60 * 24 * 7, // 1 Week
pushPlugin: true,
plugins: ['~/plugins/google-optimize.js'],
excludeBots: true,
botExpression: /(bot|spider|crawler)/i
}
}
Would it be enough then to add option to disable ga event?
Hello, can we merge this please? I'm also interested in using GTM instead of separate GA implementation @farzadso
Since this repo seems to be unmaintained I've created a fork of @eljass his code and created a new package on npm nuxt-google-optimize-next
This PR is inspired from #13. That PR seems inactive so this will address the need for GTM integration.
Adds the possibility to use @nuxtjs/gtm-module or custom tag manager implementation with the possibility to rename used dataLayer variable.
This PR adds three options to implement sending experiment info:
options.dataLayer: DATA_LAYER_NAME