-
Notifications
You must be signed in to change notification settings - Fork 0
/
referral_page.html
103 lines (86 loc) · 4.28 KB
/
referral_page.html
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>referral-cookies | Track and save the sources of your visitors</title>
<meta name="description" content="Create one or two cookies with referral sources of user that visit the website">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<style>
.container {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
@media (min-width: 768px) {
.container {
width: 750px;
}
}
@media (min-width: 992px) {
.container {
width: 970px;
}
}
@media (min-width: 1200px) {
.container {
width: 1170px;
}
}
</style>
</head>
<body>
<!--[if lte IE 9]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="https://browsehappy.com/">upgrade your browser</a> to improve your experience and security.</p>
<![endif]-->
<div style="margin: 50px auto; text-align: center;" class="container">
<h4>Same domain not change the last time utm_referral_returned cookie value</h4>
<h4>it will be stored only from a referral source outside this website</h4>
<a href="index.html?utm_source=internal&utm_medium=website&utm_campaign=page">Or you can set manually utm_source/medium... for save it over same website</a>
</div>
<div style="margin: 50px auto;" class="container">
<div style="width: 40%; min-width: 200px; float: left;">
<h3>Output of first time suorce <code>`utm_referral`</code></h3>
<p id="utm_referral"></p>
<hr>
<p id="utm_referral_frmt"></p>
</div>
<div style="width: 40%; min-width: 200px; float: right;">
<h3>Output of last time source <code>`utm_referral_returned`</code></h3>
<p id="utm_referral_returned"></p>
<hr>
<p id="utm_referral_returned_frmt"></p>
</div>
<hr style="clear: both; float: none;">
<p style="color: #999; text-align: center;">Used decodeURIComponent(...) for decode cookie content</p>
<p style="color: #FF3F00; text-align: center;">See also the dev console output <code>F12</code> or <code>Ctrl+Maiusc+J</code></p>
</div>
</body>
<script src="utm_referral-cookie.js"></script>
<script>
/* For test purpose, you can get the cookie params in this way */
// this return the cookie as it is (so you must decode it fo read)
var session = crumbleCookie('utm_referral'),
session2 = crumbleCookie('utm_referral_returned');
// First time session (only the first time visit)
if (typeof session != 'undefined') {
// use decodeURIComponent(...) for get the full cookie string
document.getElementById('utm_referral').innerHTML = decodeURIComponent(session);
// use readLogic('cookie_name') for retrieve object with configured $cookie_params
console.log(readLogic('utm_referral')); // object {source, medium, campaign, term, content}
// use cookieToString(...) for format to string
console.log(cookieToString('utm_referral')); // formatted string "source (medium | campaign | term: term | content: content)"
document.getElementById('utm_referral_frmt').innerText = cookieToString('utm_referral');
}
// Last time session (ever the last time visit)
if (typeof session2 != 'undefined') {
// use decodeURIComponent(...) for get the full cookie string
document.getElementById('utm_referral_returned').innerHTML = decodeURIComponent(session2);
// use readLogic('cookie_name') for retrieve object with configured $cookie_params
console.log(readLogic('utm_referral_returned')); // object {source, medium, campaign, term, content}
// use cookieToString(...) for format to string
console.log(cookieToString('utm_referral_returned')); // formatted string "source (medium | campaign | term: term | content: content)"
document.getElementById('utm_referral_returned_frmt').innerText = cookieToString('utm_referral_returned');
}
</script>