Skip to content

setUserProperties to GA could be setup with 'user_properties'Β #465

@phillipwildhirt

Description

@phillipwildhirt

I'm submitting a update/feature request for GA4.

  • bug report
  • feature request
  • question about the decisions made in the repository



New GA4 requires an object {user_properties: {prop1: 'value', prop2: 'value'}} set in the 'config' script in order for custom dimensions to be picked up as User scoped custom dimensions.

Currently setDimensionsAndMetrics() in ga cleans out top level dimensions and metrics, such as 'dimension1', 'dimension2', which will be deprecated with new GA4, but user_properties sent to setUserProperties is being attached using this, and they are buried, and not cleaned.



Excerpt from src/lib/providers/ga/ga.ts, line 224:

    // clean previously used dimensions and metrics that will not be overriden
    this.dimensionsAndMetrics.forEach(elem => {
      if (!properties.hasOwnProperty(elem)) {
        ga('set', elem, undefined);

        this.angulartics2.settings.ga.additionalAccountNames.forEach(
          (accountName: string) => {
            ga(`${accountName}.set`, elem, undefined);
          },
        );
      }
    });
    this.dimensionsAndMetrics = [];





I believe a rethink of the setUserProperties behavior is needed, as I'm having a hard time getting consistent user_properties delivered to the event_track every time.



Environment:

Angular CLI: 13.2.5
Node: 16.14.0
Package Manager: npm 8.3.1
OS: darwin x64

Package Version

@angular-devkit/architect 0.1302.6
@angular-devkit/build-angular 13.2.5
@angular-devkit/core 13.2.6
@angular-devkit/schematics 13.2.5
@angular/cli 13.2.5
@angular/elements 14.0.0
@schematics/angular 13.2.5
rxjs 7.5.7
typescript 4.5.5

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