PageSourceSearch

https://finimpulse.com/wp-content/plugins/dataforseo-marketing-1.0.0/js/website-marketing.js?ver=1.2.2

js finimpulse.com collected 2026-10-04 21:46:41 UTC 10,506 bytes, 283 lines download raw bytes

1document.addEventListener('DOMContentLoaded', function () {
2	const host = window.location.hostname.replace(/^www\./, '');
3	const all_domains = "." + host;
4    const cookie_ttl = 365;
5
6	const urlParams = new URLSearchParams(window.location.search);
7	
8	// Process 'aff' parameter
9	if (urlParams.has('aff')) {
10		const refid = urlParams.get('aff');
11		if (refid) {
12			Cookies.remove('connector_aff_id', { path: '', domain: all_domains });
13			const checkAffid = Cookies.get('aff_id');
14			if (checkAffid === undefined || checkAffid !== refid) {
15				Cookies.set('aff_id', refid, { domain: all_domains, expires: cookie_ttl });
16			}
17		}
18	}
19	
20	// Process 'connector_aff' parameter
21	if (urlParams.has('connector_aff')) {
22		const connectorRefid = urlParams.get('connector_aff');
23		if (connectorRefid) {
24			Cookies.remove('aff_id', { path: '', domain: all_domains });
25			const checkConnectorAffid = Cookies.get('connector_aff_id');
26			if (checkConnectorAffid === undefined || checkConnectorAffid !== connectorRefid) {
27				Cookies.set('connector_aff_id', connectorRefid, { domain: all_domains, expires: cookie_ttl });
28			}
29		}
30	}
31	
32	// Process 'promo_aff' parameter
33	if (urlParams.has('promo_aff')) {
34		const promoAff = urlParams.get('promo_aff');
35		if (promoAff) {
36			const checkPromoAff = Cookies.get('promo_aff');
37			if (checkPromoAff === undefined || checkPromoAff !== promoAff) {
38				Cookies.set('promo_aff', promoAff, { domain: all_domains, expires: cookie_ttl });
39			}
40		}
41	}
42	
43	// Process 'ps_xid' and 'ps_partner_key' parameters
44	['ps_xid', 'ps_partner_key'].forEach(function (paramName) {
45		if (!urlParams.has(paramName)) {
46			return;
47		}
48		const paramValue = urlParams.get(paramName);
49		if (!paramValue) {
50			return;
51		}
52		if (Cookies.get(paramName) !== paramValue) {
53			Cookies.set(paramName, paramValue, { domain: all_domains, expires: cookie_ttl });
54		}
55		localStorage.setItem(paramName, paramValue);
56	});
57	
58	var gclid = null;
59	var utm_source = 'none';
60	var utm_campaign = 'none';
61	var utm_term = 'none';
62	var utm_content = 'none';
63	var utm_medium = 'none';
64	
65	// LANDING PAGE LOGIC
66	const myDomains = [
67		'finimpulse.com',
68		'dataforseo.com',
69		'dataimpulse.com',
70		'seoinsider.com'
71	];
72
73	const getReferrerDomain = (url) => {
74		try {
75			return new URL(url).hostname;
76		} catch {
77			return '';
78		}
79	};
80
81	const referrerDomain = getReferrerDomain(document.referrer);
82	const isFromMyDomain = myDomains.some(domain => referrerDomain.includes(domain));
83
84	if (!document.referrer || !isFromMyDomain) {
85		Cookies.set('landing_page', document.location.href, {
86			domain: all_domains,
87			expires: cookie_ttl
88		});
89	}
90	
91	if(window.location.search.indexOf('gclid=') > -1 && window.location.search.split("gclid=").length > 1) {
92		utm_source = 'google';
93		utm_medium = 'cpc';
94		
95		gclid = window.location.search.split("gclid=")[1];
96		if(gclid.split("&").length > 1) {
97			gclid = gclid.split("&")[0];
98		}
99		if(gclid.split("GA1.2.").length > 1) {
100			gclid = gclid.split("GA1.2.")[0];
101		}
102		
103		if(window.location.search.indexOf('utm_campaign=') > -1 && window.location.search.split("utm_campaign=").length > 1) {
104			utm_campaign = window.location.search.split("utm_campaign=")[1];
105			if(utm_campaign.split("&").length > 1) {
106				utm_campaign = utm_campaign.split("&")[0];
107			}
108		} else if(window.location.search.indexOf('campaignid=') > -1 && window.location.search.split("campaignid=").length > 1) {
109			utm_campaign = window.location.search.split("campaignid=")[1];
110			if(utm_campaign.split("&").length > 1) {
111				utm_campaign = utm_campaign.split("&")[0];
112			}
113		}
114		
115		if(window.location.search.indexOf('utm_term=') > -1 && window.location.search.split("utm_term=").length > 1) {
116			utm_term = window.location.search.split("utm_term=")[1];
117			if(utm_term.split("&").length > 1) {
118				utm_term = utm_term.split("&")[0];
119			}
120		} else if(window.location.search.indexOf('keyword=') > -1 && window.location.search.split("keyword=").length > 1) {
121			utm_term = window.location.search.split("keyword=")[1];
122			if(utm_term.split("&").length > 1) {
123				utm_term = utm_term.split("&")[0];
124			}
125		}
126		
127		if(window.location.search.indexOf('utm_content=') > -1 && window.location.search.split("utm_content=").length > 1) {
128			utm_content = window.location.search.split("utm_content=")[1];
129			if(utm_content.split("&").length > 1) {
130				utm_content = utm_content.split("&")[0];
131			}
132		}
133		
134	} else if ( (window.location.search.indexOf('utm_source=') > -1 && window.location.search.split("utm_source=").length > 1) ||
135		(window.location.search.indexOf('utm_medium=') > -1 && window.location.search.split("utm_medium=").length > 1) ||
136		(window.location.search.indexOf('utm_campaign=') > -1 && window.location.search.split("utm_campaign=").length > 1) ||
137		(window.location.search.indexOf('utm_term=') > -1 && window.location.search.split("utm_term=").length > 1) ||
138		(window.location.search.indexOf('utm_content=') > -1 && window.location.search.split("utm_content=").length > 1) ||
139		(window.location.search.indexOf('campaignid=') > -1 && window.location.search.split("campaignid=").length > 1) ||
140		(window.location.search.indexOf('keyword=') > -1 && window.location.search.split("keyword=").length > 1) ) {
141		
142		if(window.location.search.indexOf('utm_source=') > -1 && window.location.search.split("utm_source=").length > 1) {
143			utm_source = window.location.search.split("utm_source=")[1];
144			if(utm_source.split("&").length > 1) {
145				utm_source = utm_source.split("&")[0];
146			}
147		}
148		
149		if(window.location.search.indexOf('utm_medium=') > -1 && window.location.search.split("utm_medium=").length > 1) {
150			utm_medium = window.location.search.split("utm_medium=")[1];
151			if(utm_medium.split("&").length > 1) {
152				utm_medium = utm_medium.split("&")[0];
153			}
154		}
155		
156		if(window.location.search.indexOf('utm_campaign=') > -1 && window.location.search.split("utm_campaign=").length > 1) {
157			utm_campaign = window.location.search.split("utm_campaign=")[1];
158			if(utm_campaign.split("&").length > 1) {
159				utm_campaign = utm_campaign.split("&")[0];
160			}
161		} else if(window.location.search.indexOf('campaignid=') > -1 && window.location.search.split("campaignid=").length > 1) {
162			utm_campaign = window.location.search.split("campaignid=")[1];
163			if(utm_campaign.split("&").length > 1) {
164				utm_campaign = utm_campaign.split("&")[0];
165			}
166		}
167		
168		if(window.location.search.indexOf('utm_term=') > -1 && window.location.search.split("utm_term=").length > 1) {
169			utm_term = window.location.search.split("utm_term=")[1];
170			if(utm_term.split("&").length > 1) {
171				utm_term = utm_term.split("&")[0];
172			}
173		} else if(window.location.search.indexOf('keyword=') > -1 && window.location.search.split("keyword=").length > 1) {
174			utm_term = window.location.search.split("keyword=")[1];
175			if(utm_term.split("&").length > 1) {
176				utm_term = utm_term.split("&")[0];
177			}
178		}
179		
180		if(window.location.search.indexOf('utm_content=') > -1 && window.location.search.split("utm_content=").length > 1) {
181			utm_content = window.location.search.split("utm_content=")[1];
182			if(utm_content.split("&").length > 1) {
183				utm_content = utm_content.split("&")[0];
184			}
185		}
186		
187	} else if (document.referrer && document.referrer.length > 1){
188		var referrer = document.referrer;
189		referrer = referrer.replace(/(https?:\/\/)?(www.)?/i, '');
190		if (referrer.indexOf('/') !== -1) {
191			referrer = referrer.split('/')[0];
192		}
193		
194		if(referrer.indexOf('google.') !== -1) {
195			referrer = 'google';
196		}
197		if(referrer.indexOf('bing.') !== -1) {
198			referrer = 'bing';
199		}
200		if(referrer.indexOf('yahoo.') !== -1) {
201			referrer = 'yahoo';
202		}
203		
204		utm_source = referrer;
205		utm_medium = 'referral';
206		if(utm_source === 'google' || utm_source === 'bing' || utm_source === 'yahoo') {
207			utm_medium = 'organic';
208		} else if(referrer.indexOf(host) !== -1) {
209			utm_medium = 'none';
210			utm_source = 'direct';
211		}
212		
213	} else {
214		utm_source = 'direct';
215	}
216
217	if(!Cookies.get('utm_source') || Cookies.get('utm_source') === undefined ||
218		(Cookies.get('utm_source') !== undefined
219			// && document.referrer
220			&& document.referrer.indexOf(location.origin) === -1
221			&& document.referrer.indexOf(host) === -1 && utm_source !== 'direct')) {
222		Cookies.set('gclid', gclid, { domain: all_domains, expires: cookie_ttl });
223		localStorage.setItem('gclid', gclid);
224		
225		Cookies.set('utm_source', utm_source, { domain: all_domains, expires: cookie_ttl });
226		localStorage.setItem('utm_source', utm_source);
227		
228		Cookies.set('utm_medium', utm_medium, { domain: all_domains, expires: cookie_ttl });
229		localStorage.setItem('utm_medium', utm_medium);
230		
231		Cookies.set('utm_campaign', utm_campaign, { domain: all_domains, expires: cookie_ttl });
232		localStorage.setItem('utm_campaign', utm_campaign);
233		
234		Cookies.set('utm_term', utm_term, { domain: all_domains, expires: cookie_ttl });
235		localStorage.setItem('utm_term', utm_term);
236		
237		Cookies.set('utm_content', utm_content, { domain: all_domains, expires: cookie_ttl });
238		localStorage.setItem('utm_content', utm_content);
239		
240		// console.log('save');
241		// console.log('gclid', gclid);
242		// console.log('utm_source', utm_source);
243		// console.log('utm_medium', utm_medium);
244		// console.log('utm_campaign', utm_campaign);
245		// console.log('utm_term', utm_term);
246		// console.log('utm_content', utm_content);
247	} 
248	// else {
249	// 	console.log('ignore');
250	// 	console.log('gclid', gclid);
251	// 	console.log('utm_source', utm_source);
252	// 	console.log('utm_medium', utm_medium);
253	// 	console.log('utm_campaign', utm_campaign);
254	// 	console.log('utm_term', utm_term);
255	// 	console.log('utm_content', utm_content);
256		
257	// }
258	
259	// old
260	if(document.referrer && document.referrer.indexOf(location.origin) === -1 && document.referrer.split('/').length > 2 && document.referrer.split('/')[2]) {
261		if(document.referrer.split('/')[2].indexOf('ranksonic.com') === -1 && document.referrer.split('/')[2].indexOf('rankactive.com') === -1
262			&& document.referrer.split('/')[2].indexOf(host) === -1) {
263			Cookies.set('referrer', document.referrer, { domain: all_domains, expires: cookie_ttl });
264		}
265	}
266	if(window.location.search.length > 0) {
267		let params = window.location.search;
268		if (params) {
269			for (let i = 1; i < 6; i++) {
270				if (Cookies.get('referrer_params_' + i) && window.location.search === Cookies.get('referrer_params_' + i)) {
271					break;
272				}
273				if (!Cookies.get('referrer_params_' + i)) {
274					Cookies.set('referrer_params_' + i, params, {
275						domain: all_domains,
276						expires: cookie_ttl
277					});
278					break;
279				}
280			}
281		}
282	}
283}, false);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.