DavidWells / DavidWells/analytics

@analytics/google-analytics: Not being able to track custom dimension

Open
#90 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.7k
Forks
267
PR merge metrics
No merged PRs in 30d

Description

Hi,

I really like the library. But I have a weird issue I am not able to solve and also looking through the docs and checking the code did not help. I am trying to add a custom dimension in Google Analytics' browser for a page.

Analytics({
  app: 'my-app',
  plugins: [
    googleAnalytics({
      trackingId: 'my-tracking-id',
      anonymizeIp: true,
      customDimensions: {
        userState: 'dimension1',
      },
    }),
  ],
}),

later I call the following

// i tried
this.analytics.page({}, { userState: true });
// also
this.analytics.page({}, { customDimensions: { userState:  true } });

but looking at the code it seems that custom dimensions are tried to be found in PageData instead of the passed options. This of course does not work because PageData types do only allow certain keys

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the googleAnalytics plugin's page entry point and inspect how PageData and the options passed to analytics.page are used for custom dimensions. Reproduce the two page calls from the issue and verify that a configured userState dimension is sent to Google Analytics from the intended input.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
analytics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.