Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Experiment is not set on Google Analytics #50

Open
asokawotulo opened this issue Jun 10, 2021 · 0 comments
Open

Experiment is not set on Google Analytics #50

asokawotulo opened this issue Jun 10, 2021 · 0 comments

Comments

@asokawotulo
Copy link

Description

I noticed that there was a discrepancy between the total number of sessions and the experiment sessions that were reported on Google Analytics.

After enabling the debug option for Google Analytics I noticed that the ga("set", "exp", exp) wasn't being called consistently.

Below is a workaround using @nuxtjs/google-analytics that seems to work for now.

// experiments.client.js
export default ({ $ga, $exp: { experimentID, $variantIndexes } }) => {
  if (!experimentID) return;
  const exp = experimentID + "." + $variantIndexes.join("-");
  $ga.set("exp", exp);
};
// nuxt.config.js
extendPlugins(plugins) {
  plugins.push("~/plugins/experiments.client.js");
  return plugins;
}

Reproduction

https://codesandbox.io/s/nuxt-google-optimize-issue-vkmho

What is Expected?

Console should output:

Executing Google Analytics commands.
Running command: ga("set", "exp", "test.0")

What is actually happening?

The command ga("set", "exp", "test.0") was never called

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant