File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 122122 function init ( ) {
123123 const params = new URLSearchParams ( location . search ) ;
124124
125- const shouldSetCookie = ( ) => {
125+ const shouldSetCookie = ( clickId ) => {
126+ const existingClickId = cookieManager . get ( DUB_ID_VAR ) ;
127+ // only set cookie if there's no existing click id
128+ // or if the attribution model is last-click and the new click id is different from the existing one
126129 return (
127- ! cookieManager . get ( DUB_ID_VAR ) || ATTRIBUTION_MODEL !== 'first-click'
130+ ! existingClickId ||
131+ ( ATTRIBUTION_MODEL === 'last-click' && clickId !== existingClickId )
128132 ) ;
129133 } ;
130134
131135 // Direct click ID in URL
132136 const clickId = params . get ( DUB_ID_VAR ) ;
133- if ( clickId && shouldSetCookie ( ) ) {
137+ if ( clickId && shouldSetCookie ( clickId ) ) {
134138 cookieManager . set ( DUB_ID_VAR , clickId ) ;
135139 setPartnerData ( clickId ) ;
136140 return ;
137141 }
138142
139143 // Track via query param
140144 if ( QUERY_PARAM_VALUE && SHORT_DOMAIN ) {
141- if ( shouldSetCookie ( ) ) {
145+ if ( shouldSetCookie ( clickId ) ) {
142146 trackClick ( QUERY_PARAM_VALUE ) ;
143147 }
144148 }
You can’t perform that action at this time.
0 commit comments