Merged
Conversation
Mudaafi
reviewed
Apr 23, 2025
src/modules/tracker.js
Outdated
Comment on lines
71
to
91
| const utmSource = searchParams.get('utm_source'); | ||
| const utmMedium = searchParams.get('utm_medium'); | ||
| const utmCampaign = searchParams.get('utm_campaign'); | ||
|
|
||
| // Add UTM parameters to origin_referrer if they exist | ||
| if (utmSource || utmMedium || utmCampaign) { | ||
| aggregateParams.origin_referrer += '?'; | ||
|
|
||
| if (utmSource) { | ||
| aggregateParams.origin_referrer += `utm_source=${utmSource}`; | ||
| } | ||
|
|
||
| if (utmMedium) { | ||
| if (utmSource) aggregateParams.origin_referrer += '&'; | ||
| aggregateParams.origin_referrer += `utm_medium=${utmMedium}`; | ||
| } | ||
|
|
||
| if (utmCampaign) { | ||
| if (utmSource || utmMedium) aggregateParams.origin_referrer += '&'; | ||
| aggregateParams.origin_referrer += `utm_campaign=${utmCampaign}`; | ||
| } |
Contributor
There was a problem hiding this comment.
Might I suggest an alternative?
const utmParamKeys = ['utm_source', 'utm_medium', 'utm_campaign'];
const utmQueryParamStrArr = [];
utmParamKeys.forEach((key) => {
const utmParamValue = searchParams.get(key);
if (utmParamValue) {
utmQueryParamStrArr.push(`${key}=${utmParamValue}`);
}
});
if (utmQueryParamStrArr.length) {
aggregateParams.origin_referrer += `?${utmQueryParamStrArr.join('&')}`
}Not to nitpick on implementation, but something like this would make it easier if we needed to add in more utm fields in the future
Co-authored-by: Ahmad Mudaafi' <[email protected]>
esezen
requested changes
Apr 28, 2025
Co-authored-by: Enes Kutay SEZEN <[email protected]>
jjl014
approved these changes
Apr 28, 2025
| const utmParameters = 'utm_source=attentive&utm_medium=sms&utm_campaign=campaign_1'; | ||
| const url = `http://localhost.test/path/name?query=term&category=cat&${utmParameters}`; | ||
|
|
||
| function validateOriginReferrer(requestParams) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Support for UTM parameters
Where?
Appended to the
origin_referrerparameter intracker.jsmoduleWhat are the supported parameters
Tests
validateOriginReferrer