Skip to content

Commit

Permalink
Add in code to check for utm tags in queries
Browse files Browse the repository at this point in the history
  • Loading branch information
iyasinn committed Dec 2, 2024
1 parent a5ff530 commit f1ea342
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,30 @@ interface Props {
export const getServerSideProps: GetServerSideProps = async ({
params,
req,
query,
}) => {
const slug = params?.slug as string[];
const slugRoute = slug.join("/");

if (query.utm_tag) {
const utmTag = query.utm_tag;
console.log("UTM parameter detected:", utmTag);

const { data: utmData } = await supabase
.from("utm")
.select()
.eq("tag", utmTag)
.single();

if (utmData) {
await supabase.from("utm_clicks").insert({
utm_tag: utmData.tag,
});
} else {
console.log("Could not find any utm entry for tag: ", utmTag);
}
}

const { data } = await supabase
.from<DynamicLinkData>("dynamic_links")
.select()
Expand Down

0 comments on commit f1ea342

Please sign in to comment.