Skip to content

Commit

Permalink
Merge pull request #1473 from appwrite/feat-add-referrer-and-utm-to-c…
Browse files Browse the repository at this point in the history
…ontact-form-submit

Add the referrer and utm source to the contact form submissions
  • Loading branch information
ernstmul authored Dec 17, 2024
2 parents 0eb7746 + d4a8e9a commit e703fcd
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/lib/utils/utm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export function getReferrerAndUtmSource() {
if (sessionStorage) {
let values = {};
if (sessionStorage.getItem('referrer')) {
values = { ...values, referrer: sessionStorage.getItem('referrer') };
}
if (sessionStorage.getItem('utmSource')) {
values = { ...values, utmSource: sessionStorage.getItem('utmSource') };
}

return values;
}
return {};
}
6 changes: 6 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
if (ref || referrer || utmSource || utmCampaign || utmMedium) {
createSource(ref, referrer, utmSource, utmCampaign, utmMedium);
}
if (referrer) {
sessionStorage.setItem('referrer', referrer);
}
if (utmSource) {
sessionStorage.setItem('utmSource', utmSource);
}
const initialTheme = $page.route.id?.startsWith('/docs') ? getPreferredTheme() : 'dark';
applyTheme(initialTheme);
Expand Down
4 changes: 3 additions & 1 deletion src/routes/contact-us/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import MainFooter from '../../lib/components/MainFooter.svelte';
import { socials } from '$lib/constants';
import { PUBLIC_GROWTH_ENDPOINT } from '$env/static/public';
import { getReferrerAndUtmSource } from '$lib/utils/utm';
let email = '';
let firstName = '';
Expand All @@ -25,7 +26,8 @@
email,
firstName,
subject,
message
message,
...getReferrerAndUtmSource()
})
});
if (response.status >= 400) {
Expand Down
4 changes: 3 additions & 1 deletion src/routes/contact-us/enterprise/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import Pink from '../bg.png';
import { loggedIn, user } from '$lib/utils/console';
import { PUBLIC_GROWTH_ENDPOINT } from '$env/static/public';
import { getReferrerAndUtmSource } from '$lib/utils/utm';
let email = '';
let name = '';
Expand Down Expand Up @@ -36,7 +37,8 @@
companySize,
companyWebsite,
firstName: name,
message: useCase
message: useCase,
...getReferrerAndUtmSource()
})
});
Expand Down
4 changes: 3 additions & 1 deletion src/routes/integrations/technology-partner/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//import BlobPink from "$routes/startups/(assets)/blob-pink.svg";
// import BlobPinkMobile from "$routes/startups/(assets)/blob-pink-mobile.svg";
import Pink from './bg.png';
import { getReferrerAndUtmSource } from '$lib/utils/utm';
import { PUBLIC_GROWTH_ENDPOINT } from '$env/static/public';
let email = '';
Expand Down Expand Up @@ -40,7 +41,8 @@
email,
firstName: name,
subject,
message
message,
...getReferrerAndUtmSource()
})
});
if (response.status >= 400) {
Expand Down
4 changes: 3 additions & 1 deletion src/routes/oss-program/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { socials } from '$lib/constants';
import GradientBackground from './bg.png';
import { PUBLIC_GROWTH_ENDPOINT } from '$env/static/public';
import { getReferrerAndUtmSource } from '$lib/utils/utm';
let personName = '';
let personEmail = '';
Expand Down Expand Up @@ -35,7 +36,8 @@
githubUrl,
websiteUrl,
license,
message
message,
...getReferrerAndUtmSource()
})
});
if (response.status >= 400) {
Expand Down
4 changes: 3 additions & 1 deletion src/routes/startups/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { PUBLIC_GROWTH_ENDPOINT } from '$env/static/public';
import Faq from './faq.svelte';
import { getReferrerAndUtmSource } from '$lib/utils/utm';
const title = 'Startups' + TITLE_SUFFIX;
const description = DEFAULT_DESCRIPTION;
Expand Down Expand Up @@ -58,7 +59,8 @@
personName,
personEmail,
companyName,
companyUrl: companyUrl.startsWith('http') ? companyUrl : `https://${companyUrl}`
companyUrl: companyUrl.startsWith('http') ? companyUrl : `https://${companyUrl}`,
...getReferrerAndUtmSource()
})
});
Expand Down

0 comments on commit e703fcd

Please sign in to comment.