Skip to content

Commit

Permalink
Push a new is using AI dataLayer variable on the Search page to GTM
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjarling committed Jun 24, 2024
1 parent fefc1cd commit 97addd0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/ga/data-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface DataLayer {
adminset?: string;
collections?: string | null;
creatorsContributors?: Array<string> | string;
isUsingAI?: boolean;
isLoggedIn?: boolean;
pageTitle: string;
rightsStatement?: string | null;
Expand All @@ -15,6 +16,7 @@ const defaultDataLayer = {
adminset: "",
collections: "",
creatorsContributors: "",
isUsingAI: false,
isLoggedIn: false,
pageTitle: "",
rightsStatement: "",
Expand Down
10 changes: 7 additions & 3 deletions pages/search.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as Tabs from "@radix-ui/react-tabs";

import { GetServerSideProps, NextPage } from "next";
import {
NoResultsMessage,
ResultsMessage,
Expand All @@ -21,7 +22,6 @@ import Heading from "@/components/Heading/Heading";
import Icon from "@/components/Shared/Icon";
import { IconSparkles } from "@/components/Shared/SVG/Icons";
import Layout from "@/components/layout";
import { NextPage } from "next";
import { PRODUCTION_URL } from "@/lib/constants/endpoints";
import PaginationAltCounts from "@/components/Search/PaginationAltCounts";
import SearchOptions from "@/components/Search/Options";
Expand Down Expand Up @@ -280,8 +280,12 @@ const SearchPage: NextPage = () => {
);
};

export async function getStaticProps() {
export const getServerSideProps: GetServerSideProps = async (context) => {
const { query } = context;
const isUsingAI = query?.ai === "true";

const dataLayer = buildDataLayer({
isUsingAI,
pageTitle: "Search page",
});

Expand All @@ -293,6 +297,6 @@ export async function getStaticProps() {
return {
props: { dataLayer, openGraphData },
};
}
};

export default SearchPage;

0 comments on commit 97addd0

Please sign in to comment.