This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrow.js
49 lines (42 loc) · 1.63 KB
/
grow.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(function($) {
/**
* Initialize sourcebuster.js.
*/
sbjs.init({
lifetime: grow_params.life,
session_length: grow_params.session,
timezone_offset: '0', // utc
});
/**
* Set values.
*/
var setFields = function() {
if (sbjs.get) {
$('input[name="grow_source_type"]').val(sbjs.get.current.typ);
$('input[name="grow_source_url"]').val(sbjs.get.current_add.rf);
$('input[name="grow_source_mtke"]').val(sbjs.get.current.mtke);
$('input[name="grow_source_utm_campaign"]').val(sbjs.get.current.cmp);
$('input[name="grow_source_utm_source"]').val(sbjs.get.current.src);
$('input[name="grow_source_utm_medium"]').val(sbjs.get.current.mdm);
$('input[name="grow_source_utm_content"]').val(sbjs.get.current.cnt);
$('input[name="grow_source_utm_id"]').val(sbjs.get.current.id);
$('input[name="grow_source_utm_term"]').val(sbjs.get.current.trm);
$('input[name="grow_source_session_entry"]').val(sbjs.get.current_add.ep);
$('input[name="grow_source_session_start_time"]').val(sbjs.get.current_add.fd);
$('input[name="grow_source_session_pages"]').val(sbjs.get.session.pgs);
$('input[name="grow_source_session_count"]').val(sbjs.get.udata.vst);
}
};
/**
* Add source values to checkout.
*/
$(document.body).on('init_checkout', function(event) {
setFields();
});
/**
* Add source values to register.
*/
if ($('.woocommerce form.register').length) {
setFields();
}
})(jQuery);