Skip to content

Commit

Permalink
[IST-707] Add all utm parameters we should be able to track
Browse files Browse the repository at this point in the history
  • Loading branch information
hcoura committed Jan 6, 2020
1 parent 9a02090 commit 394f058
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
40 changes: 26 additions & 14 deletions assets/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ function getQueryStrParam(name, url) {
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}

function maybeStoreUtmSource() {
var utm_source = getQueryStrParam('utm_source');
if (utm_source) {
Cookies.set('utm_source', utm_source);
}
function storeUrlParam(param_name) {
var hasCookie = getStoredParam(param_name);
if (hasCookie == "" || hasCookie) return;
var param = getQueryStrParam(param_name) || "";
Cookies.set(param_name, param, {domain: ".scrapinghub.com", expires: 90})
}

function maybeStoreGclid() {
var gclid = getQueryStrParam("gclid", window.location.search);
if (gclid) {
Cookies.set("gclid", gclid);
}
function getStoredParam(param_name) {
return Cookies.get(param_name, {domain: ".scrapinghub.com"})
}

jQuery(function ($) {
Expand All @@ -37,11 +34,26 @@ jQuery(function ($) {
update_region_info(region_data);
});

maybeStoreUtmSource();
maybeStoreGclid();
storeUrlParam("utm_campaign");
storeUrlParam("utm_activity");
storeUrlParam("utm_medium");
storeUrlParam("utm_source");
storeUrlParam("utm_content");
storeUrlParam("utm_primary");
storeUrlParam("utm_secondary");
storeUrlParam("utm_goal");

storeUrlParam("gclid");

$('#gclid').val(Cookies.get('gclid'));
$('#utm_source').val(Cookies.get('utm_source'));
$('#gclid').val(getStoredParam("gclid"));
$('#utm_campaign').val(getStoredParam('utm_campaign'));
$('#utm_activity').val(getStoredParam('utm_activity'));
$('#utm_medium').val(getStoredParam('utm_medium'));
$('#utm_source').val(getStoredParam('utm_source'));
$('#utm_content').val(getStoredParam('utm_content'));
$('#utm_primary').val(getStoredParam('utm_primary'));
$('#utm_secondary').val(getStoredParam('utm_secondary'));
$('#utm_goal').val(getStoredParam('utm_goal'));

$.get("https://ipapi.co/json/", function (x) {
$("#country").val(x["country_name"]);
Expand Down
10 changes: 9 additions & 1 deletion request.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@ <h2>Fill out this form to request a <span>training</span></h2>
method="POST">

<input type="hidden" id="country" name="country" value="" />
<input type="hidden" id="utm_source" name="utm_source" value="" />
<input type="hidden" id="city" name="city" value="" />

<input type="hidden" id="gclid" name="gclid" value="" />
<input type="hidden" id="ga_cid" name="ga_cid" value="" />
<input type="hidden" id="submission_url" name="submission_url" value="" />
<input type="hidden" id="tag_manager_user_id" name="tag_manager_user_id" value="" />

<input type="hidden" id="utm_campaign" name="utm_campaign" value="" />
<input type="hidden" id="utm_activity" name="utm_activity" value="" />
<input type="hidden" id="utm_medium" name="utm_medium" value="" />
<input type="hidden" id="utm_source" name="utm_source" value="" />
<input type="hidden" id="utm_content" name="utm_content" value="" />
<input type="hidden" id="utm_primary" name="utm_primary" value="" />
<input type="hidden" id="utm_secondary" name="utm_secondary" value="" />
<input type="hidden" id="utm_goal" name="utm_goal" value="" />

<div class="basic-info">
<div class="row">
Expand Down Expand Up @@ -162,4 +169,5 @@ <h3>Your team expertise</h3>
</form>
</div>
</div>
</div>
</section>

0 comments on commit 394f058

Please sign in to comment.