From 3907f1e0409805e53cd9b242f6a1905f35f49df9 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 18 Apr 2024 11:02:52 +0700 Subject: [PATCH 1/2] Update Customer Account setup guide --- README.md | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 07279b5b..1660b631 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ export async function loader(args: RouteLoaderArgs) { let {params, context} = args; return defer({ - weaverseData: await context.weaverse.loadPage(), + weaverseData: await context.weaverse.loadPage({type: 'INDEX'}), // More route's loader data... }); } @@ -274,21 +274,24 @@ Weaverse provides a convenient way to customize your theme inside the **Weaverse ![Weaverse Editor](https://cdn.shopify.com/s/files/1/0838/0052/3057/files/playground.jpg?v=1699244445) -## Setup for using Customer Account API (`/account` section) +## Setup for using Customer Account API (`/account`) -### Setup public domain using Cloudflare Tunnel - -1. Use [untun](https://github.com/unjs/untun) to start a tunnel with your public domain +1. Run development with `--customer-account-push__unstable` flag to start the server with a tunnel to expose the local server to the public domain. +```bash +shopify hydrogen dev --codegen --port 3456 --customer-account-push__unstable +``` +Or quicker way with: ```bash -npx untun@latest tunnel http://localhost:3456 +npm run dev:ca ``` ### Include public domain in Customer Account API settings +After run the server with `--customer-account-push__unstable` flag, you will get a public domain like `https://.tryhydrogen.dev`. And it should be automatically added to the Customer Account API settings. If not, you can manually add it by following these steps: 1. Go to your Shopify admin => `Hydrogen` or `Headless` app/channel => Customer Account API => Application setup -1. Edit `Callback URI(s)` to include `https://.trycloudflare.com/account/authorize` -1. Edit `Javascript origin(s)` to include your public domain `https://.trycloudflare.com` or keep it blank -1. Edit `Logout URI` to include your public domain `https://.trycloudflare.com` or keep it blank +2. Edit `Callback URI(s)` to include `https://.tryhydrogen.dev/account/authorize` +3. Edit `Javascript origin(s)` to include your public domain `https://.tryhydrogen.dev` or keep it blank +4. Edit `Logout URI` to include your public domain `https://.tryhydrogen.dev` or keep it blank ### Local development inspects From f61c8bd49648385130517ab166507d45f3dcdc2e Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 18 Apr 2024 11:31:51 +0700 Subject: [PATCH 2/2] Update Google Tag setup --- .env.example | 1 + app/components/GoogleTagManager.tsx | 35 ++++++++++++++++++++++++++ app/root.tsx | 5 +++- app/weaverse/create-weaverse.server.ts | 3 ++- env.d.ts | 1 + 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 app/components/GoogleTagManager.tsx diff --git a/.env.example b/.env.example index b694c378..41fdc6c9 100644 --- a/.env.example +++ b/.env.example @@ -10,4 +10,5 @@ PUBLIC_CHECKOUT_DOMAIN=checkout.hydrogen.shop #WEAVERSE_PROJECT_ID="your-project-id" #WEAVERSE_API_KEY="your-weaverse-api-key" #WEAVERSE_HOST="https://studio.weaverse.io" +#PUBLIC_GOOGLE_GTM_ID=G-R1KFYYKE48 diff --git a/app/components/GoogleTagManager.tsx b/app/components/GoogleTagManager.tsx new file mode 100644 index 00000000..ec0eefec --- /dev/null +++ b/app/components/GoogleTagManager.tsx @@ -0,0 +1,35 @@ +import {useLoaderData} from '@remix-run/react'; +import {Script} from '@shopify/hydrogen'; +import {loader} from '~/root'; + +export function GoogleGTM() { + const data = useLoaderData(); + let id = data.googleGtmID; + if (!id) { + return null; + } + + return ( + <> + {/* Initialize GTM container */} +