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

Experiment is not set on Google Analytics #50

Description

@asokawotulo

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions