Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

nick-Ag
Copy link
Contributor

@nick-Ag nick-Ag commented Dec 30, 2021

Since custom events sent to google cannot include spaces in the event name, this removes spaces before sending and introduces a toggle for users to convert the event name to lowercase.

Testing

Tested in staging and all looks good:
Screen Shot 2022-01-04 at 11 27 43 AM
Screen Shot 2022-01-04 at 11 27 55 AM

  • Added unit tests for new functionality
  • Tested end-to-end using the local server
  • [Segmenters] Tested in the staging environment

@nick-Ag
Copy link
Contributor Author

nick-Ag commented Dec 30, 2021

Going to leave this as a draft PR until I deploy & test in staging, and until after change freeze ends on Tuesday

import { client_id } from '../ga4-properties'

const normalize_event_name = (name: string, lowercase: boolean | undefined): string => {
name = name.trim()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trim so we can avoid outputting something like: ___Event_Name__

@nick-Ag nick-Ag marked this pull request as ready for review January 4, 2022 19:55
@kdaswani
Copy link
Contributor

kdaswani commented Jan 4, 2022

@nick-Ag Can we update the Event Name description in the Custom Event action to say something like this?

description: 'The unique name of the custom event created in GA4. GA4 does not accept spaces in event names so Segment will replace any spaces with underscores. More information about GA4 event name rules is available in [their docs](https://support.google.com/analytics/answer/10085872?hl=en&ref_topic=9756175#event-name-rules&zippy=%2Cin-this-article.%2Cin-this-article). ',

import type { Payload } from './generated-types'
import { client_id } from '../ga4-properties'

const normalize_event_name = (name: string, lowercase: boolean | undefined): string => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, camelCase would be convention for function names, but not a blocker.

@nick-Ag nick-Ag merged commit 1afefe4 into main Jan 5, 2022
@nick-Ag nick-Ag deleted the ga4-normalize branch January 5, 2022 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants