PageSourceSearch

https://www.veriff.com/wp-content/themes/veriff/js/google-helpers-for-hubspot-forms.js?ver=1.2.0.live_422

js veriff.com collected 2026-10-02 02:54:47 UTC 4,352 bytes, 120 lines download raw bytes

1/**
2 * Capture Google Client ID and Google Click ID values from the website.
3 *
4 * Declare the following JavaScript needs to be present in each page where we collect the data
5 * regardless of the method used to integrate Hubspot:
6 */
7
8// Client id
9function getClientId() {
10	const match = document.cookie.match(/_ga=GA\d\.\d\.(\d+\.\d+)/);
11	return match ? match[1] : '1111111111.2222222222';
12}
13
14// Gclid
15function getGclid() {
16	const cookieName = '_gcl_aw';
17	const cookie = document.cookie.match(new RegExp('(^| )' + cookieName + '=([^;]+)'));
18	// Google Ads creates cookies in the following format: {version}.{timestamp_in_seconds}.{google_ads_click_id__c}
19	if (cookie) return cookie[2].split('.').pop();
20}
21
22// Gclid Expire Date
23function getExp() {
24	const cookieName = '_gcl_aw';
25
26	const cookie = document.cookie.match(new RegExp('(^| )' + cookieName + '=([^;]+)'));
27	// Google Ads creates cookies in the following format: {version}.{timestamp_in_seconds}.{google_ads_click_id__c}
28	if (cookie) {
29		return new Date(cookie[2].split('.')[1] * 1000 + 864e5 * 90).toISOString();
30	} // 90-day expiry window
31}
32
33// Session_id
34function getSessionId() {
35	const cookieName = '_ga_G57E138DKB';
36	const cookie = document.cookie.match(new RegExp('(^| )' + cookieName + '=([^;]+)'));
37
38	if (cookie && cookie[2]) {
39		const value = cookie[2];
40
41		const newFormatMatch = value.match(/s(\d+)\$/);
42		if (newFormatMatch) {
43			return newFormatMatch[1];
44		}
45
46		const parts = value.split('.');
47		if (parts.length >= 4) {
48			return parts[3];
49		}
50	}
51
52	return null;
53}
54
55// Referral
56function getReferral() {
57	return getCookie('veriff_orig_ref');
58}
59
60// UTMs
61function getCookie(cookie_name) {
62	const c_name = cookie_name + '=';
63	const cookie_decoded = decodeURIComponent(document.cookie);
64	const cookie_parts = cookie_decoded.split(';');
65
66	for (let i = 0; i < cookie_parts.length; i++) {
67		let c = cookie_parts[i];
68		while (c.charAt(0) === ' ') {
69			c = c.substring(1);
70		}
71		if (c.indexOf(c_name) === 0) {
72			return c.substring(c_name.length, c.length);
73		}
74	}
75	return '';
76}
77
78function appendTracking($form) {
79	if (!$form) return;
80
81	try {
82		// GA
83		const clientId = getClientId() || '';
84		const gclid = getGclid() || '';
85		const expireDate = getExp() || '';
86		const sessionId = getSessionId() || '';
87		const referral = getReferral() || '';
88
89		$form.find('input[name="gaclientid__c"]').val(clientId).change();
90		$form.find('input[name="google_ads_click_id__c"]').val(gclid).change();
91		$form.find('input[name="google_ads_click_id_expiration__c"]').val(expireDate).change();
92		$form.find('input[name="google_analytics_session_id__c"]').val(sessionId).change();
93		$form.find('input[name="google_analytics_referral___c"]').val(referral).change();
94
95		// Campaign UTMs
96		const all_utms = getCookie('all_utm')?.split('&');
97		const utm_source = all_utms.find((param) => param.includes('utm_source'))?.split('=')[1] || '';
98		const utm_medium = all_utms.find((param) => param.includes('utm_medium'))?.split('=')[1] || '';
99		const utm_campaign = all_utms.find((param) => param.includes('utm_campaign'))?.split('=')[1] || '';
100		const utm_term = all_utms.find((param) => param.includes('utm_term'))?.split('=')[1] || '';
101		const utm_content = all_utms.find((param) => param.includes('utm_content'))?.split('=')[1] || '';
102		// const utm_group = all_utms.find((param) => param.includes('utm_group'))?.split('=')[1] || '';
103		const utm_adgroup = all_utms.find((param) => param.includes('utm_adgroup'))?.split('=')[1] || '';
104		// const hsa_grp = all_utms.find((param) => param.includes('hsa_grp'))?.split('=')[1] || '';
105		const sfcid = all_utms.find((param) => param.includes('sfcid'))?.split('=')[1] || '';
106		const sfaid = all_utms.find((param) => param.includes('sfaid'))?.split('=')[1] || '';
107
108		$form.find('input[name="utm_source___c"]').val(utm_source).change();
109		$form.find('input[name="utm_medium___c"]').val(utm_medium).change();
110		$form.find('input[name="utm_campaign___c"]').val(utm_campaign).change();
111		$form.find('input[name="utm_term___c"]').val(utm_term).change();
112		$form.find('input[name="utm_content___c"]').val(utm_content).change();
113		$form.find('input[name="utm_ad_group___c"]').val(utm_adgroup).change();
114		// Salesforce
115		$form.find('input[name="sfcid"]').val(sfcid).change();
116		$form.find('input[name="sfaid"]').val(sfaid).change();
117	} catch (error) {
118		console.error(error);
119	}
120}

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.