Giter VIP home page Giter VIP logo

Comments (8)

tammaroivan avatar tammaroivan commented on May 22, 2024 2

Great! I'll try it today.

Thank you for the article 🙂

from analytics.

DavidWells avatar DavidWells commented on May 22, 2024

Hey @tammaroivan

Custom dimensions were on my list of this to do... 😃

I went ahead and added them: https://github.com/DavidWells/analytics/blob/master/packages/analytics-plugin-google-analytics/src/browser.js#L11

I need to clean up the docs & then I can release a new version for ya.

In the newer version, once released, you can define customDimensions option and map to your google analytics custom dimensions.

Here is an example:

import Analytics from 'analytics'
import googleAnalytics from '@analytics/google-analytics'

/* initialize analytics and load plugins */
const analytics = Analytics({
  app: 'awesome-app',
  plugins: [
    googleAnalytics({
      trackingId: 'UA-1223141231',
      // Map your dimensions here
      customDimensions: {
        baz: 'dimension1',
        foo: 'dimension2',
        flam: 'dimension3',
      },
    }),
  ]
})

// Tracking example with mappings
analytics.track('buttonClicked', {
   baz: 'hello',
   foo: 'cool'
})
/* This tracking call payload maps to:
{
  dimension1: 'hello', ===> baz is mapped to dimension1
  dimension2: 'cool'   ===> foo is mapped to dimension1
}

Under the hood this sets the custom dimensions in GA:

ga('set', {  dimension1: 'hello', dimension2: 'cool' }).     */

// Mapping works with identify too
analytics.identify('user123', {
   flam: 'wow'
})
/* This identify call payload maps to:
{
  dimension3: 'wow', ===> flam is mapped to dimension3
}
a.k.a ga('set', {  dimension3: 'wow' }). 
*/

Out of curiosity, what are you tracking with custom dimensions? Also, are you using custom metrics at all? Thanks!

from analytics.

tammaroivan avatar tammaroivan commented on May 22, 2024

Thank you so much for that! Waiting for that release.

I'm dealing with a specific problem. I need reports associated to the user id, I'm identifying the user with analytics.identify but Google Analytics really doesn't allow you to do so much else than "User Explorer" (or I couldn't find it).

One basic example: I'm saving a specific event and I would like to know which user does this event more times. I couldn't find how to do this with the user id feature but yes with a custom dimension.

I'm not using custom metrics for now, but I'm just starting this project in my company and it will get bigger in the near future.

What do you think? Custom dimension is a good approach for this? Or can I do this with the user id feature?

Thanks!

from analytics.

DavidWells avatar DavidWells commented on May 22, 2024

Alrighty! @analytics/[email protected] is published with custom dimension support.

Thanks again for reaching out & using the package! 😃

As for which custom dimensions to track, I've always liked Simo's https://www.simoahava.com/analytics/13-useful-custom-dimensions-for-google-analytics/ list.

from analytics.

omarciovsena avatar omarciovsena commented on May 22, 2024

am i doing something wrong?

I'm not able to load the values sent to customDimensions into Google Analytics

import googleAnalytics from '@analytics/google-analytics'
import Analytics from 'analytics'

const analytics = Analytics({
  app: 'app',
  version: 100,
  plugins: [
    googleAnalytics({
      trackingId: process.env.GA_TRACKING_ID,
      customDimensions: {
        feature: 'dimension1',
        subfeature: 'dimension2',
        version: 'dimension3',
        chapter: 'dimension4',
        verse: 'dimension5',
        ip: 'dimension6',
        isHowToUse: 'dimension7'
      }
    })
  ]
})
await analytics.track('request', {
   feature: 'verses',
   subfeature: 'search'
})

Using the default properties (action, category and label) it worked.

In Google Analytics:

Captura de Tela 2020-06-12 às 17 49 49

Captura de Tela 2020-06-12 às 17 45 46
Captura de Tela 2020-06-12 às 17 45 52

from analytics.

DavidWells avatar DavidWells commented on May 22, 2024

Hey @marciovsena

That looks correct as per the docs https://getanalytics.io/plugins/google-analytics/#using-ga-custom-dimensions

Do you have a live project/link I can checkout?

setCustomDimensions should be getting called here

const dimensions = setCustomDimenions(payload.properties, opts, instancePrefix)
which sets the dimensions before the tracking event is called
ga(`${instancePrefix}set`, customDimensions)

from analytics.

omarciovsena avatar omarciovsena commented on May 22, 2024

@DavidWells Yes, I am apparently doing as described in the documentation.

Link of the PR with the implementation:

Application Staging Link:

I was unable to add your hello@davi... email to the google analytics staging account.

How to test:

Thank you

from analytics.

brandonbronisz avatar brandonbronisz commented on May 22, 2024

To anyone else that was having this issue, i had to manually pull the release. Perhaps a release for this wasn't published.

Doing a fresh npm install was pulling 0.2.2

from analytics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.