Repository navigation
feat: capture click IDs from other ad platforms with the clickParams option - #224
Merged
Merged
Conversation
…S and Display & Video 360
…parameters # Conflicts: # test/utm.test.ts
…parameters # Conflicts: # src/runtime/utm.ts
… into feat/click-params # Conflicts: # README.md # src/runtime/utm.ts
Member
Author
|
Review notes before merging:
|
# Conflicts: # README.md # src/runtime/parameters.ts # src/runtime/utm.ts # test/utm.test.ts
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.
Campaign visits from Meta, Microsoft Advertising, TikTok, LinkedIn, and other ad platforms arrive with their own click IDs, such as
fbclidormsclkid. The module only recognizes UTM and Google parameters, so withcaptureWithoutCampaign: falsethese visits are dropped, and otherwise they are saved as direct visits that never become first or last touch. The README suggested readingfbclidin autm:before-persisthook, which stores it incustomParamsbut still leaves the visit outside attribution.The new
clickParamsoption lists extra query parameter names to capture:A visit with a nonempty value for any listed name is a campaign visit. Its values are saved in the entry's new optional
clickParamsfield and count towardcaptureWithoutCampaign, first touch, last touch, and deduplication, the same way UTM and Google click parameters do.src/runtime/utm.tsaddsurlHasClickParamsandgetClickParams, built on the helpers from feat: capture GA4 campaign parameters and Google click IDs used on iOS and Display & Video 360 #223. The helpers read only the query's own properties, so a configured name such asconstructorcannot match what every object inherits.isRepeatedEntrycompares every stored click ID, not only the currently configured names, so changing the list between visits cannot hide a new click.src/runtime/history.tsaccepts stored entries whoseclickParamsis a string map, andgetCampaignTouchestreats them as campaigns.src/options.tsholds the build time option checks. The existingmaxAgeandmaxEntrieschecks moved there fromsrc/module.tsunchanged.clickParamsmust be a list of nonempty names without surrounding spaces, and it cannot include a UTM or Google click parameter, because those are already captured inutmParamsandgclidParams; the error names the field.src/runtime/parameters.tsholds that name rule, and the plugin applies it to the runtime config too. A runtime override such asNUXT_PUBLIC_UTM_CLICK_PARAMS=fbclid,msclkidarrives as a string and skips the build time checks, so the plugin ignores anything that is not a valid list instead of failing every capture.fbclidto a non-clickpromovalue so it no longer points click IDs atcustomParams. It also says to list only the click IDs a site's consent policy covers, and that every query parameter stays inadditionalInfo.landingPageUrlunless a hook redacts it.There are no defaults, so existing sites capture exactly what they did before. Design choices worth a reviewer's opinion:
clickParams, mirroringutmParamsandgclidParams. The option is a list of names and the field is a map of values.gclid, fails the build. That keepsclickParamslimited to other platforms' click IDs, so a backend that counts click IDs across both maps cannot countgclidtwice. The option is new, so this excludes no existing configuration.The unit, history, options, and browser integration tests were written first and failed for the intended reasons: the helpers were missing, history ignored
clickParams, the options module did not exist, and the integration fixture saved no entry within the timeout. They pass with the change. The later tests for whitespace and built-in names, inherited names, and a string runtime override also failed first, and the test for a visit without click IDs after one with them fails if deduplication compares only the current entry's keys.Validation:
pnpm lint --max-warnings 0,pnpm format:check,pnpm test:types,pnpm dev:build,pnpm test(113 tests),pnpm test:package, andpnpm test:compatibilityon Nuxt 4.6.1 and Nuxt 3.21.11 pass.