Skip to content

Commit

Permalink
feat: track UTM query parameters (backport)
Browse files Browse the repository at this point in the history
This PR adds support for tracking UTM query parameters under the `utm` checkpoint.
All UTM parameters will be captured except for the `utm_id` which could be PII.

## Related Issues

Fix #137
  • Loading branch information
ramboz authored Mar 22, 2024
2 parents 7a17f3e + c6e2491 commit c988ee6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,11 @@ const observer = new PerformanceObserver((list) => {
}
});
observer.observe({ type: 'resource', buffered: true });

const usp = new URLSearchParams(window.location.search);
[...usp.entries()]
.filter(([key]) => key.startsWith('utm_'))
.filter(([key]) => key !== 'utm_id')
.forEach(([key, value]) => {
sampleRUM('utm', { source: key, target: value });
});

0 comments on commit c988ee6

Please sign in to comment.