Skip to content

feat: add Pinterest click ID capture (epik/_epik)#1126

Closed
jciafardone wants to merge 25 commits into
mParticle:developmentfrom
jciafardone:patch-1
Closed

feat: add Pinterest click ID capture (epik/_epik)#1126
jciafardone wants to merge 25 commits into
mParticle:developmentfrom
jciafardone:patch-1

Conversation

@jciafardone

@jciafardone jciafardone commented Dec 6, 2025

Copy link
Copy Markdown

Add Pinterest epik and _epik parameter mapping to integrationMappingExternal.

Testing:

  • Added comprehensive tests covering both epik and _epik variants
  • Tests verify capture from all three sources (query params, cookies, localStorage)
  • Tests verify proper mapping to custom flags

Background

  • Pinterest uses both epik (query parameter) and _epik (cookie) to track click IDs
  • The epik parameter is appended by Pinterest to ad click URLs
  • The _epik cookie is stored by Pinterest's tag
  • Both variants need to be captured to ensure comprehensive click ID tracking
  • Pinterest requires the click ID to be sent as Pinterest.click_id custom flag for Pinterest Conversions API (CAPI) integration
  • Currently, the SDK captures click IDs for Facebook, Google, TikTok, and Snapchat, but not Pinterest
  • This change adds Pinterest to the list of supported integration-specific identifier captures

What Has Changed

  • Added epik parameter mapping to integrationMappingExternal in integrationCapture.ts
  • Added _epik parameter mapping to integrationMappingExternal in integrationCapture.ts
  • Both epik and _epik map to Pinterest.click_id custom flag
  • Each parameter variant is checked in all three sources:
    • Query parameters (e.g., ?epik=value or ?_epik=value)
    • Cookies (e.g., epik=value or _epik=value)
    • localStorage (e.g., localStorage.getItem('epik') or localStorage.getItem('_epik'))
  • Follows standard priority resolution: query params > localStorage > cookies
  • Outputs to CUSTOM_FLAGS (consistent with other click ID integrations like gclid, fbclid, ttclid)
  • No processor function needed (unlike Facebook's fbclid which requires formatting)

Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have tested this locally.

Additional Notes

  • Tested extraction logic locally using standalone browser test file
  • Verified capture from URL query params, cookies, and localStorage for both epik and _epik variants
  • Confirmed priority resolution works correctly (query > localStorage > cookie)
  • Validated custom flag mapping to Pinterest.click_id
  • Verified that when both variants are present, both map to the same custom flag key
  • This change is additive and does not affect existing integrations
  • No breaking changes introduced

Add Pinterest _epik parameter mapping to integrationMappingExternal.

- Maps _epik to Pinterest.click_id custom flag
- Supports capture from URL query params, cookies, and localStorage
- Follows standard priority: query params > localStorage > cookies
- Outputs to CUSTOM_FLAGS (same as other click ID integrations)

Reference: https://help.pinterest.com/en/business/article/add-event-codes

Testing:
- Verified extraction from URL, cookie, and localStorage sources
- Confirmed priority resolution works correctly
- Validated custom flag mapping to Pinterest.click_id
@jciafardone jciafardone changed the base branch from master to development December 8, 2025 17:56
@rmi22186 rmi22186 force-pushed the development branch 3 times, most recently from a790359 to 0ba2d13 Compare December 10, 2025 15:31
Comment thread src/integrationCapture.ts Outdated
Comment thread src/integrationCapture.ts Outdated
@rmi22186 rmi22186 force-pushed the development branch 2 times, most recently from 905641c to b16bdd2 Compare December 10, 2025 21:07
jciafardone and others added 2 commits December 17, 2025 13:22
Co-authored-by: Alex S <49695018+alexs-mparticle@users.noreply.github.com>
- Add epik parameter mapping in addition to _epik
- Both epik and _epik map to Pinterest.click_id custom flag
- Support capture from query params, cookies, and localStorage
- Add comprehensive tests for both parameter variants
- Reference: https://developers.pinterest.com/docs/track-conversions/track-conversions-in-the-api/
@rmi22186

Copy link
Copy Markdown
Member

@jciafardone - looks like @alexs-mparticle 's comment here still hasn't been updated- 2dfa771#r2607709893

is his docs link correct? If so, please update.

@rmi22186

Copy link
Copy Markdown
Member

@jciafardone there's also some conflicts now, can you resolve, commit, and force push to this branch?

@jciafardone jciafardone changed the title feat(integration): add Pinterest _epik click ID capture feat(integration): add Pinterest click ID capture (epik/_epik) Jan 13, 2026
Comment thread src/integrationCapture.ts

@rmi22186 rmi22186 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hit approve too soon. left one coment @jciafardone

added output for _epik
@sonarqubecloud

Copy link
Copy Markdown

@jciafardone jciafardone requested a review from rmi22186 January 16, 2026 23:28
Comment thread test/jest/integration-capture.spec.ts Outdated
});
});

it('should map both epik and _epik to Pinterest.click_id', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This test is failing. can you address? @jciafardone

jciafardone and others added 2 commits March 6, 2026 16:46
Co-authored-by: Robert Ing <rmi22186@gmail.com>
@sonarqubecloud

sonarqubecloud Bot commented Mar 7, 2026

Copy link
Copy Markdown

@jciafardone jciafardone requested a review from rmi22186 March 10, 2026 20:59
@rmi22186 rmi22186 requested a review from a team as a code owner March 12, 2026 15:01
@jciafardone

Copy link
Copy Markdown
Author

hi @rmi22186 , just wanted to circle back on this. Was there anything else I needed to do on this to be able to merge?

Stub epik in getQueryParams and expect Pinterest.click_id on events,
matching the Snap integration test pattern.
@cursor

cursor Bot commented May 14, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Low risk, additive support for new Pinterest identifiers with explicit precedence rules and expanded test coverage; minimal chance of impacting existing integrations beyond the capture merge logic.

Overview
Adds Pinterest click ID support by capturing epik and _epik from query params, cookies, and localStorage and mapping both to the Pinterest.click_id custom flag.

Implements Pinterest precedence rules in IntegrationCapture.capture() (query params override localStorage/cookies; localStorage overrides cookies) and refactors/extends Jest and integration tests to cover the new IDs and the precedence behavior.

Reviewed by Cursor Bugbot for commit c5abf7d. Bugbot is set up for automated code reviews on this repo. Configure here.

Extract expectCapturedSnapchatAndPinterestFlags helper to satisfy
duplication threshold on new code.
- Add expectCapturedGoogleFacebookFlags helper
- Remove duplicate commerce it blocks (identical copies)
Comment thread src/integrationCapture.ts
Comment thread test/jest/integration-capture.spec.ts Outdated
- expectStubbedIntegrationCaptureFlags wraps Google/Facebook + Snap/Pinterest
- Shared commerce purchase helpers and constants
- logThreeEventsUploadAndParseBatch for batch upload tests
Replace duplicated event/pageview and commerce it() bodies with
CAPTURE_CUSTOM_FLAG_CASES and COMMERCE_CAPTURE_CASES tables.
…stomFlags block

- Fix indentation and close describe before partner identities suite
- Use stable assertions (toBeDefined + includes) per review
Sonar rule javascript:S7764 prefers globalThis over window in tests; behavior unchanged under jsdom.
Satisfies Sonar no-zero-fraction rule; value unchanged.
A missing brace nested _scid under _epik and broke integrationMappingExternal parsing. Restore _scid as a top-level key next to Pinterest entries.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 84979c4. Configure here.

Comment thread src/integrationCapture.ts
Assert both Pinterest source keys are registered in filtered mappings, then that Pinterest.click_id is one of the input values (same key, last-write wins).
epik and _epik map to the same custom flag. Prefer query params over localStorage and cookies, then localStorage over cookies, mirroring Facebook fbclid/_fbc and Rokt-style precedence. Add Jest coverage for each tier.
Add clickIdsAfterFullCaptureAllMode helper; drive Pinterest, Snapchat, and Rokt #capture cases from tables; consolidate capture V2 mode gating tests.
… tests

Restores Window augmentation typing for mParticle (fixes rollup TS2352). Sonar may flag window again; acceptable tradeoff.
@sonarqubecloud

Copy link
Copy Markdown

@jciafardone jciafardone changed the title feat(integration): add Pinterest click ID capture (epik/_epik) feat: add Pinterest click ID capture (epik/_epik) May 14, 2026
@jciafardone jciafardone deleted the patch-1 branch May 14, 2026 20:00
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