Skip to content

Commit e703fcd

Browse files
authored
Merge pull request #1473 from appwrite/feat-add-referrer-and-utm-to-contact-form-submit
Add the referrer and utm source to the contact form submissions
2 parents 0eb7746 + d4a8e9a commit e703fcd

File tree

7 files changed

+35
-5
lines changed

7 files changed

+35
-5
lines changed

src/lib/utils/utm.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export function getReferrerAndUtmSource() {
2+
if (sessionStorage) {
3+
let values = {};
4+
if (sessionStorage.getItem('referrer')) {
5+
values = { ...values, referrer: sessionStorage.getItem('referrer') };
6+
}
7+
if (sessionStorage.getItem('utmSource')) {
8+
values = { ...values, utmSource: sessionStorage.getItem('utmSource') };
9+
}
10+
11+
return values;
12+
}
13+
return {};
14+
}

src/routes/+layout.svelte

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@
7474
if (ref || referrer || utmSource || utmCampaign || utmMedium) {
7575
createSource(ref, referrer, utmSource, utmCampaign, utmMedium);
7676
}
77+
if (referrer) {
78+
sessionStorage.setItem('referrer', referrer);
79+
}
80+
if (utmSource) {
81+
sessionStorage.setItem('utmSource', utmSource);
82+
}
7783
const initialTheme = $page.route.id?.startsWith('/docs') ? getPreferredTheme() : 'dark';
7884
7985
applyTheme(initialTheme);

src/routes/contact-us/+page.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import MainFooter from '../../lib/components/MainFooter.svelte';
77
import { socials } from '$lib/constants';
88
import { PUBLIC_GROWTH_ENDPOINT } from '$env/static/public';
9+
import { getReferrerAndUtmSource } from '$lib/utils/utm';
910
1011
let email = '';
1112
let firstName = '';
@@ -25,7 +26,8 @@
2526
email,
2627
firstName,
2728
subject,
28-
message
29+
message,
30+
...getReferrerAndUtmSource()
2931
})
3032
});
3133
if (response.status >= 400) {

src/routes/contact-us/enterprise/+page.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import Pink from '../bg.png';
88
import { loggedIn, user } from '$lib/utils/console';
99
import { PUBLIC_GROWTH_ENDPOINT } from '$env/static/public';
10+
import { getReferrerAndUtmSource } from '$lib/utils/utm';
1011
1112
let email = '';
1213
let name = '';
@@ -36,7 +37,8 @@
3637
companySize,
3738
companyWebsite,
3839
firstName: name,
39-
message: useCase
40+
message: useCase,
41+
...getReferrerAndUtmSource()
4042
})
4143
});
4244

src/routes/integrations/technology-partner/+page.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//import BlobPink from "$routes/startups/(assets)/blob-pink.svg";
1010
// import BlobPinkMobile from "$routes/startups/(assets)/blob-pink-mobile.svg";
1111
import Pink from './bg.png';
12+
import { getReferrerAndUtmSource } from '$lib/utils/utm';
1213
import { PUBLIC_GROWTH_ENDPOINT } from '$env/static/public';
1314
1415
let email = '';
@@ -40,7 +41,8 @@
4041
email,
4142
firstName: name,
4243
subject,
43-
message
44+
message,
45+
...getReferrerAndUtmSource()
4446
})
4547
});
4648
if (response.status >= 400) {

src/routes/oss-program/+page.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { socials } from '$lib/constants';
88
import GradientBackground from './bg.png';
99
import { PUBLIC_GROWTH_ENDPOINT } from '$env/static/public';
10+
import { getReferrerAndUtmSource } from '$lib/utils/utm';
1011
1112
let personName = '';
1213
let personEmail = '';
@@ -35,7 +36,8 @@
3536
githubUrl,
3637
websiteUrl,
3738
license,
38-
message
39+
message,
40+
...getReferrerAndUtmSource()
3941
})
4042
});
4143
if (response.status >= 400) {

src/routes/startups/+page.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
2020
import { PUBLIC_GROWTH_ENDPOINT } from '$env/static/public';
2121
import Faq from './faq.svelte';
22+
import { getReferrerAndUtmSource } from '$lib/utils/utm';
2223
2324
const title = 'Startups' + TITLE_SUFFIX;
2425
const description = DEFAULT_DESCRIPTION;
@@ -58,7 +59,8 @@
5859
personName,
5960
personEmail,
6061
companyName,
61-
companyUrl: companyUrl.startsWith('http') ? companyUrl : `https://${companyUrl}`
62+
companyUrl: companyUrl.startsWith('http') ? companyUrl : `https://${companyUrl}`,
63+
...getReferrerAndUtmSource()
6264
})
6365
});
6466

0 commit comments

Comments
 (0)