@@ -40,28 +40,28 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
40
40
'twclid' ,
41
41
] ;
42
42
43
- // Get client ID from script tag
43
+ // Get pixel ID from script tag
44
44
const scriptTag = document . currentScript ;
45
45
const scriptUrl = scriptTag . src ;
46
46
47
47
// Parse query string manually
48
- const getClientId = ( url ) => {
48
+ const getPixelId = ( url ) => {
49
49
const queryString = url . split ( '?' ) [ 1 ] ;
50
50
if ( ! queryString ) return null ;
51
51
52
52
const params = new URLSearchParams ( queryString ) ;
53
- return params . get ( 'clientId ' ) ;
53
+ return params . get ( 'pixelId ' ) ;
54
54
} ;
55
55
56
- const clientId = getClientId ( scriptUrl ) ;
56
+ const pixelId = getPixelId ( scriptUrl ) ;
57
57
58
- if ( ! clientId ) {
58
+ if ( ! pixelId ) {
59
59
console . error ( 'Pixel ID is required' ) ;
60
60
return ;
61
61
}
62
62
63
- const CLIENT_ID = clientId . toUpperCase ( ) ;
64
- const SESSION_KEY = `_source_link_${ CLIENT_ID } ` ;
63
+ const PIXEL_ID = pixelId . toUpperCase ( ) ;
64
+ const SESSION_KEY = `_source_link_${ PIXEL_ID } ` ;
65
65
66
66
// Utility Functions
67
67
const getCookie = ( name ) => {
@@ -104,7 +104,7 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
104
104
if ( ! response . ok ) {
105
105
if ( response . status === 403 ) {
106
106
console . warn (
107
- `🚫 SourceLink disabled - Pixel ${ CLIENT_ID } is inactive` ,
107
+ `🚫 SourceLink disabled - Pixel ${ PIXEL_ID } is inactive` ,
108
108
) ;
109
109
} else {
110
110
console . warn ( `⚠️ Source tracking error - Status: ${ response . status } ` ) ;
@@ -141,15 +141,15 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
141
141
} ;
142
142
143
143
// Core Functions
144
- const validateClient = async ( ) => {
144
+ const validatePixel = async ( ) => {
145
145
const cachedStatus = sessionStorage . getItem ( SESSION_KEY ) ;
146
146
if ( cachedStatus !== null ) {
147
147
return cachedStatus === 'true' ;
148
148
}
149
149
150
150
const validationData = {
151
151
action : ACTIONS . VALIDATE ,
152
- clientId : CLIENT_ID ,
152
+ pixelId : PIXEL_ID ,
153
153
websiteId : PAGE_DOMAIN ,
154
154
visitorId : 'validation_check' ,
155
155
} ;
@@ -170,7 +170,7 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
170
170
171
171
const firestoreData = {
172
172
action : ACTIONS . CREATE_VISITOR ,
173
- clientId : CLIENT_ID ,
173
+ pixelId : PIXEL_ID ,
174
174
websiteId : PAGE_DOMAIN ,
175
175
visitorId : visitorId ,
176
176
createdAt : Date . now ( ) ,
@@ -182,7 +182,7 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
182
182
183
183
if ( response . success ) {
184
184
const cookieData = {
185
- clientId : CLIENT_ID ,
185
+ pixelId : PIXEL_ID ,
186
186
websiteId : PAGE_DOMAIN ,
187
187
visitorId : visitorId ,
188
188
referrer : data . sourceData [ 0 ] . referrer ,
@@ -203,7 +203,7 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
203
203
const updateFirestoreWithNewSource = async ( visitorId , newData ) => {
204
204
const updateData = {
205
205
action : ACTIONS . UPDATE_SOURCE ,
206
- clientId : CLIENT_ID ,
206
+ pixelId : PIXEL_ID ,
207
207
websiteId : PAGE_DOMAIN ,
208
208
visitorId : visitorId ,
209
209
sourceData : [ newData ] ,
@@ -239,7 +239,7 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
239
239
if ( visitorId ) {
240
240
const data = {
241
241
action : ACTIONS . UPDATE_EMAIL ,
242
- clientId : CLIENT_ID ,
242
+ pixelId : PIXEL_ID ,
243
243
websiteId : PAGE_DOMAIN ,
244
244
visitorId : visitorId ,
245
245
email : email ,
@@ -327,9 +327,9 @@ const cloudFunctionUrl = "https://us-west1-ms-source-tracking-tool-dev.cloudfunc
327
327
328
328
// Initialize the app
329
329
const init = async ( ) => {
330
- const isActive = await validateClient ( ) ;
330
+ const isActive = await validatePixel ( ) ;
331
331
if ( ! isActive ) {
332
- console . warn ( `🚫 SourceLink disabled - Pixel ${ CLIENT_ID } is inactive` ) ;
332
+ console . warn ( `🚫 SourceLink disabled - Pixel ${ PIXEL_ID } is inactive` ) ;
333
333
return ;
334
334
}
335
335
0 commit comments