Skip to content
This repository was archived by the owner on May 22, 2026. It is now read-only.

Commit ae5e583

Browse files
committed
Merge remote-tracking branch 'origin/master' into staging/4.2
2 parents a3f0ed9 + a282e04 commit ae5e583

3 files changed

Lines changed: 107 additions & 2 deletions

File tree

_includes/contact-us-modal.html

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ <h2>{{ modalDescription }}</h2>
8181
</label>
8282
</div>
8383
<input type="hidden" name="_next" value="/docs/contact-us-thanks/">
84+
<input type="hidden" name="utm_source-popup" id="utm_source-popup">
85+
<input type="hidden" name="utm_medium-popup" id="utm_medium-popup">
86+
<input type="hidden" name="utm_campaign-popup" id="utm_campaign-popup">
87+
<input type="hidden" name="utm_term-popup" id="utm_term-popup">
88+
<input type="hidden" name="utm_content-popup" id="utm_content-popup">
89+
<input type="hidden" name="client_id-popup" id="client_id-popup">
8490
<input type="text" name="_gotcha" style="display:none">
8591
</div>
8692
<div class="submit-button-container">
@@ -120,6 +126,44 @@ <h2>{{ modalDescription }}</h2>
120126
}
121127
});
122128

129+
function populateUTMandClientIdFields() {
130+
var $form = $('.contact-form');
131+
if (!$form.length) return;
132+
133+
const utmKeys = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content'];
134+
const utmData = {};
135+
136+
utmKeys.forEach(function(key) {
137+
let value = getURLParam(key);
138+
if (value) {
139+
localStorage.setItem(key, value);
140+
} else {
141+
value = localStorage.getItem(key);
142+
}
143+
144+
if (value) {
145+
value = decodeURIComponent(value);
146+
utmData[key] = value;
147+
$form.find('input[name="' + key + '-popup"]').val(value);
148+
}
149+
});
150+
151+
const gaCookie = document.cookie.split('; ').find(row => row.startsWith('_ga='));
152+
if (gaCookie) {
153+
const parts = gaCookie.split('.');
154+
if (parts.length >= 4) {
155+
const clientId = parts[2] + '.' + parts[3];
156+
utmData['client_id'] = clientId;
157+
$form.find('input[name="client_id-popup"]').val(clientId);
158+
}
159+
}
160+
window.dataLayer = window.dataLayer || [];
161+
window.dataLayer.push({
162+
event: 'contact-us',
163+
...utmData
164+
});
165+
}
166+
123167
jqueryDefer(
124168
function () {
125169
$( document ).ready(function() {
@@ -128,6 +172,7 @@ <h2>{{ modalDescription }}</h2>
128172
/* $('html, body').animate({
129173
scrollTop: $('#contact-form').offset().top - 200
130174
}, 0);*/
175+
populateUTMandClientIdFields();
131176
$contactForm.find('.form-element .form-control').addClass("input--empty");
132177
$contactForm.find('.form-element .form-control').on('input', function() {
133178
if( !$(this).val() ) {
@@ -206,6 +251,11 @@ <h2>{{ modalDescription }}</h2>
206251
}
207252
}
208253

254+
function getURLParam(name) {
255+
const results = new RegExp('[?&]' + name + '=([^&#]*)').exec(window.location.href);
256+
return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null;
257+
}
258+
209259
function validateContactForm(form) {
210260
let isValid = true;
211261
const fieldsToValidate = [

docs/contact-us.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ notitle: "true"
196196
<p class="text-area-label">Message</p>
197197
</label>
198198
</div>
199+
<input type="hidden" name="utm_source" id="utm_source">
200+
<input type="hidden" name="utm_medium" id="utm_medium">
201+
<input type="hidden" name="utm_campaign" id="utm_campaign">
202+
<input type="hidden" name="utm_term" id="utm_term">
203+
<input type="hidden" name="utm_content" id="utm_content-popup">
204+
<input type="hidden" name="client_id" id="client_id">
199205
<input type="hidden" name="_next" value="/docs/contact-us-thanks/">
200206
<input type="text" name="_gotcha" style="display:none">
201207
</div>
@@ -221,11 +227,56 @@ notitle: "true"
221227
document.querySelector('.select-label').parentElement.style.display = 'none';
222228
}
223229
});
230+
231+
function getURLParam(name) {
232+
const results = new RegExp('[?&]' + name + '=([^&#]*)').exec(window.location.href);
233+
return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null;
234+
}
235+
236+
function populateUTMandClientIdFields() {
237+
var $form = $('.contact-form');
238+
if (!$form.length) return;
239+
240+
const utmKeys = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content'];
241+
const utmData = {};
242+
243+
utmKeys.forEach(function(key) {
244+
let value = getURLParam(key);
245+
if (value) {
246+
localStorage.setItem(key, value);
247+
} else {
248+
value = localStorage.getItem(key);
249+
}
250+
251+
if (value) {
252+
value = decodeURIComponent(value);
253+
utmData[key] = value;
254+
$form.find('input[name="' + key + '"]').val(value);
255+
}
256+
});
257+
258+
const gaCookie = document.cookie.split('; ').find(row => row.startsWith('_ga='));
259+
if (gaCookie) {
260+
const parts = gaCookie.split('.');
261+
if (parts.length >= 4) {
262+
const clientId = parts[2] + '.' + parts[3];
263+
utmData['client_id'] = clientId;
264+
$form.find('input[name="client_id"]').val(clientId);
265+
}
266+
}
267+
window.dataLayer = window.dataLayer || [];
268+
window.dataLayer.push({
269+
event: 'contact-us',
270+
...utmData
271+
});
272+
}
273+
224274
jqueryDefer(
225275
function () {
226276
$( document ).ready(function() {
227277
var $contactForm = $('#ContactUs');
228278
$contactForm.attr('action', 'https://formspree.io/f/xbjvbeln');
279+
populateUTMandClientIdFields();
229280
/* $('html, body').animate({
230281
scrollTop: $('#contact-form').offset().top - 200
231282
}, 0);*/

services/development-services/index.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,13 +1339,13 @@ description: "Fast delivery of scalable IoT solutions with fixed cost and timeli
13391339
<div class="form-section">
13401340
<div class="form-element">
13411341
<label for="name">
1342-
<input class="form-control cdu-form-control" value="" placeholder="John Doe" name="name" id="name" type="text" size="40" maxlength="50" aria-invalid="false">
1342+
<input class="form-control cdu-form-control" value="" placeholder="John Doe" name="name-popup" id="name-popup" type="text" size="40" maxlength="50" aria-invalid="false">
13431343
<p>Name</p>
13441344
</label>
13451345
</div>
13461346
<div class="form-element">
13471347
<label for="email">
1348-
<input class="form-control cdu-form-control" value="" placeholder="john@example.com" name="email" id="email" type="email" size="40" maxlength="80" aria-invalid="false">
1348+
<input class="form-control cdu-form-control" value="" placeholder="john@example.com" name="email-popup" id="email-popup" type="email" size="40" maxlength="80" aria-invalid="false">
13491349
<p>Email Address</p>
13501350
</label>
13511351
</div>
@@ -1896,6 +1896,10 @@ description: "Fast delivery of scalable IoT solutions with fixed cost and timeli
18961896

18971897
function onContactUsClick(index) {
18981898
handleGTMFormID(index);
1899+
const timeInput = modal.querySelector('.form-rendered-at');
1900+
if(timeInput){
1901+
$(timeInput).val(Math.floor(Date.now() / 1000));
1902+
}
18991903
modal.style.display = "flex";
19001904
}
19011905

0 commit comments

Comments
 (0)