google / google/site-kit-wp

Update event tracking to more closely align with gtag

Open
#9,044 1 comment 0 reactions 1 assignee Claimed by @aaemnnosttv View on GitHub
P1 Type: Infrastructure
Dominant language
JavaScript
Stars
1.4k
Forks
383
Avg merge
4d 12h
Merged PRs (30d)
80

Description

## Feature Description

Site Kit has long had a dedicated utility for internal event tracking instead of using `gtag` directly. This simplifies many things such as conditional calling based on whether or not the user has opted-in as well as the application of common parameters.

Since the implementation was initially built on UA, things like `event_category` were also built into the function as positional arguments.

---------------

_Do not alter or remove anything below. The following sections will be managed by moderators only._

## Acceptance criteria

- `trackEvent` should be updated to accept an alternate signature which should be the preferred method going forward:
```ts
trackEvent( name: string, params?: Object )
```
- `name` above maps to the current `action` arg (i.e. event name)
- `params` would be merged with the others that make up the event data and should use the appropriate keys accordingly
- any `undefined` values should be excluded from the resulting data
- The current signature should be allowed for backwards compatibility and all other functionality should remain unchanged

## Implementation Brief

* [ ]

### Test Coverage

*

## QA Brief

*

## Changelog entry

*

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.