Skip to content

I don't think this tool is sending user_id #11

@paradite

Description

@paradite

Per Google Analytics docs, user_id is required in order to identify a user (to differentiate new user with an existing returning user).

It is also required when sending user_data.

fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${measurement_id}&api_secret=${api_secret}`, {
  method: "POST",
  body: JSON.stringify({
    client_id: 'XXXXXXXXXX.YYYYYYYYYY',
    user_id: "XXX",
    events: [{
      name: 'purchase'
    }],
    user_data: {
      sha256_email_address: yourEmailSha256Variable,
      sha256_phone_number: yourPhoneSha256Variable,
      address: {
        sha256_first_name: yourFirstNameSha256Variable,
        sha256_last_name: yourLastNameSha256Variable,
        sha256_street: yourStreetAddressSha256Variable,
        city: yourCityVariable,
        region: yourRegionVariable,
        postal_code: yourPostalCodeVariable,
        country: yourCountryVariable
      }
    }
  })
});

However, looking at the code, it is only sending client_id, not user_id.

const payload = {
    client_id: this.clientID,
    events: [
        {
            name: eventName,
            params: {
                session_id: this.sessionID,
                ...this.customParams,
            },
        },
    ],
};

Happy to open a PR if you think this issue should be addressed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions