From 9ad994c185823958c3fb8375d1f0974d98e8693a Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Thu, 25 Apr 2024 08:06:44 +0000 Subject: [PATCH 1/7] Add screen_view, ad_impression, campaign_details events to EventBuilder --- .../schemas/eventTypes/eventDefinitions.ts | 3 ++ src/components/ga4/EventBuilder/event.ts | 41 +++++++++++++++++++ src/components/ga4/EventBuilder/types.ts | 4 +- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/components/ga4/EventBuilder/ValidateEvent/schemas/eventTypes/eventDefinitions.ts b/src/components/ga4/EventBuilder/ValidateEvent/schemas/eventTypes/eventDefinitions.ts index 7a594bf3e..65a1024e7 100644 --- a/src/components/ga4/EventBuilder/ValidateEvent/schemas/eventTypes/eventDefinitions.ts +++ b/src/components/ga4/EventBuilder/ValidateEvent/schemas/eventTypes/eventDefinitions.ts @@ -1,11 +1,13 @@ // Event and required property mapping export const eventDefinitions = { + "ad_impression": [], "add_payment_info": ["value", "items"], "add_shipping_info": ["value", "items"], "add_to_cart": ["value", "items"], "add_to_wishlist": ["value", "items"], "begin_checkout": ["value", "items"], + "campaign_details": [], "earn_virtual_currency": [], "generate_lead": ["value"], "join_group": [], @@ -15,6 +17,7 @@ export const eventDefinitions = { "purchase": ["transaction_id", "items", "value"], "refund": ["transaction_id", "value"], "remove_from_cart": ["items", "value"], + "screen_view": [], "search": ["search_term"], "select_content": [], "select_item": ["items"], diff --git a/src/components/ga4/EventBuilder/event.ts b/src/components/ga4/EventBuilder/event.ts index 75bf9fe4c..5704422b4 100644 --- a/src/components/ga4/EventBuilder/event.ts +++ b/src/components/ga4/EventBuilder/event.ts @@ -50,6 +50,19 @@ const eventFor = ( const custom_event = eventFor(EventType.CustomEvent, [Category.Custom], [], []) +const ad_impression = eventFor( + EventType.AdImpression, + [Category.AllApps], + [ + stringParam("ad_platform", "MoPub"), + stringParam("ad_source", "AdColony"), + stringParam("ad_format", "Banner"), + stringParam("ad_unit_name", "Banner_03"), + stringParam("currency", "USD"), + numberParam("value", 3.99), + ] +) + const add_payment_info = eventFor( EventType.AddPaymentInfo, [Category.RetailEcommerce], @@ -159,6 +172,19 @@ const begin_checkout = eventFor( ] ) +const campaign_details = eventFor( + EventType.CampaignDetails, + [Category.AllApps], + [ + stringParam("campaign_id", "SUMMER_FUN"), + stringParam("campaign", "Summer_fun"), + stringParam("source", "google"), + stringParam("medium", "cpc"), + stringParam("term", "summer+travel"), + stringParam("content", "logolink"), + ] +) + const earn_virtual_currency = eventFor( EventType.EarnVirtualCurrency, [Category.AllApps], @@ -274,6 +300,15 @@ const remove_from_cart = eventFor( ] ) +const screen_view = eventFor( + EventType.ScreenView, + [Category.AllApps], + [ + stringParam("screen_class", "MainActivity"), + stringParam("screen_name", "About"), + ] +) + const search = eventFor( EventType.Search, [Category.AllApps], @@ -489,6 +524,8 @@ export const suggestedEventFor = (eventType: EventType): Event2 => { case EventType.CustomEvent: return custom_event + case EventType.AdImpression: + return ad_impression case EventType.AddPaymentInfo: return add_payment_info case EventType.AddShippingInfo: @@ -499,6 +536,8 @@ export const suggestedEventFor = (eventType: EventType): Event2 => { return add_to_wishlist case EventType.BeginCheckout: return begin_checkout + case EventType.CampaignDetails: + return campaign_details case EventType.EarnVirtualCurrency: return earn_virtual_currency case EventType.GenerateLead: @@ -517,6 +556,8 @@ export const suggestedEventFor = (eventType: EventType): Event2 => { return refund case EventType.RemoveFromCart: return remove_from_cart + case EventType.ScreenView: + return screen_view case EventType.Search: return search case EventType.SelectContent: diff --git a/src/components/ga4/EventBuilder/types.ts b/src/components/ga4/EventBuilder/types.ts index 7e1f53cfa..f8d108ea8 100644 --- a/src/components/ga4/EventBuilder/types.ts +++ b/src/components/ga4/EventBuilder/types.ts @@ -28,12 +28,13 @@ export enum Category { export enum EventType { CustomEvent = "custom_event", - + AdImpression = "ad_impression", AddPaymentInfo = "add_payment_info", AddShippingInfo = "add_shipping_info", AddToCart = "add_to_cart", AddToWishlist = "add_to_wishlist", BeginCheckout = "begin_checkout", + CampaignDetails = "campaign_details", EarnVirtualCurrency = "earn_virtual_currency", GenerateLead = "generate_lead", JoinGroup = "join_group", @@ -43,6 +44,7 @@ export enum EventType { Purchase = "purchase", Refund = "refund", RemoveFromCart = "remove_from_cart", + ScreenView = "screen_view", Search = "search", SelectContent = "select_content", SelectItem = "select_item", From 934b569aaa9924c57890ddade02983e9655d11c3 Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Tue, 23 Jul 2024 01:33:19 +0000 Subject: [PATCH 2/7] remove UA toggle --- src/components/Layout/index.tsx | 20 -------------------- src/components/Layout/links.ts | 10 +--------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index 0510e054c..3944a7d6e 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -204,16 +204,6 @@ const Template: React.FC> = ({ ) } - if (linkData.type === "ga4toggle") { - return ( -
  • - -
  • - ) - } return ( > = ({ ) } - if (linkData.type === "ga4toggle") { - return ( -
  • - -
  • - ) - } return (
  • Date: Mon, 29 Jul 2024 09:54:21 +0000 Subject: [PATCH 3/7] Delete UA-GA4 toggle --- src/components/Layout/GA4Toggle.tsx | 39 ----------------------------- src/components/Layout/index.tsx | 8 ++++-- 2 files changed, 6 insertions(+), 41 deletions(-) delete mode 100644 src/components/Layout/GA4Toggle.tsx diff --git a/src/components/Layout/GA4Toggle.tsx b/src/components/Layout/GA4Toggle.tsx deleted file mode 100644 index 55fac1a18..000000000 --- a/src/components/Layout/GA4Toggle.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import * as React from "react" - -import Grid from "@mui/material/Grid/Grid" -import Switch from '@mui/material/Switch'; -import Tooltip from '@mui/material/Tooltip'; - -import { GAVersion } from "@/constants" - -interface GA4ToggleProps { - gaVersion: GAVersion - setGAVersion: (version: GAVersion) => void -} - -const GA4Toggle: React.FC = ({ setGAVersion, gaVersion }) => { - return ( - - - UA - - { - if (e.target.checked === true) { - setGAVersion(GAVersion.GoogleAnalytics4) - } else { - setGAVersion(GAVersion.UniversalAnalytics) - } - }} - name="use GA4" - color="primary" - /> - - GA4 - - - ) -} - -export default GA4Toggle diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index 3944a7d6e..9225c3365 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -41,7 +41,6 @@ import { useGAVersion } from "../../hooks" import { GAVersion, Url } from "../../constants" import Spinner from "../Spinner" import { linkData } from "./links" -import GA4Toggle from "./GA4Toggle" import BugReport from "./BugReport" import Loadable from "../Loadable" import useLogin2, { UserStatus } from "./useLogin" @@ -130,7 +129,12 @@ const Template: React.FC> = ({ const newLocation = window.location.href.replace( window.location.hostname, newHostname ); window.location.replace(newLocation); } - //}, 1000); + + if( window.location.pathname.indexOf('ga4') == -1 ) { + const newLocation = window.location.pathname = '/ga4/'; + window.location.replace(newLocation); + } + //}, 1000); return; }, []); From a03a11fd54822aa8afb145f292b6248a0c726d0c Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Thu, 29 Aug 2024 07:15:35 +0000 Subject: [PATCH 4/7] Redirect the root page to ga4 without breaking the Bitly auth. --- src/components/Layout/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index 9225c3365..de6890868 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -130,7 +130,7 @@ const Template: React.FC> = ({ window.location.replace(newLocation); } - if( window.location.pathname.indexOf('ga4') == -1 ) { + if( !window.location.search && window.location.pathname === '/' ) { const newLocation = window.location.pathname = '/ga4/'; window.location.replace(newLocation); } From 81c09914e84ee44e8cda5a18fdbbfcf8e92cd416 Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Thu, 29 Aug 2024 08:04:59 +0000 Subject: [PATCH 5/7] Remove LineItem since it is not implemented (fix presubmit failures). --- src/pages/ga4/enhanced-ecommerce/cart.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/pages/ga4/enhanced-ecommerce/cart.tsx b/src/pages/ga4/enhanced-ecommerce/cart.tsx index dc84d6fa1..d20a1e49d 100644 --- a/src/pages/ga4/enhanced-ecommerce/cart.tsx +++ b/src/pages/ga4/enhanced-ecommerce/cart.tsx @@ -17,7 +17,6 @@ import * as React from "react" import Layout from "@/components/Layout" import {Header} from "@/components/ga4/EnhancedEcommerce/header"; import {Footer} from "@/components/ga4/EnhancedEcommerce/footer"; -import {LineItem} from "@/components/ga4/EnhancedEcommerce/line-item"; import {StoreContext} from '@/components/ga4/EnhancedEcommerce/store-context'; import {collapseColumn, emptyStateContainer, emptyStateHeading, grandTotal, imageHeader, labelColumn, productHeader, summary, table, title, totals, wrap,} from "./cart.module.css" @@ -80,9 +79,6 @@ export default (props: Props) => { - {lineItems.map((item) => ( - - ))} From 9fd7e83a7187fd27f68c92406316bc39f8512e18 Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Thu, 29 Aug 2024 08:04:59 +0000 Subject: [PATCH 6/7] Fix presubmit failures. --- src/components/Spinner.tsx | 2 +- src/pages/ga4/enhanced-ecommerce/cart.tsx | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/components/Spinner.tsx b/src/components/Spinner.tsx index cdce1e407..b741a7ec2 100644 --- a/src/components/Spinner.tsx +++ b/src/components/Spinner.tsx @@ -1,7 +1,7 @@ import * as React from "react" import { styled } from '@mui/material/styles'; import { useTheme } from "@mui/material" -import {Circles} from "react-loader-spinner" +import Circles from "react-loader-spinner" import {PropsWithChildren} from 'react'; const PREFIX = 'Spinner'; diff --git a/src/pages/ga4/enhanced-ecommerce/cart.tsx b/src/pages/ga4/enhanced-ecommerce/cart.tsx index dc84d6fa1..d20a1e49d 100644 --- a/src/pages/ga4/enhanced-ecommerce/cart.tsx +++ b/src/pages/ga4/enhanced-ecommerce/cart.tsx @@ -17,7 +17,6 @@ import * as React from "react" import Layout from "@/components/Layout" import {Header} from "@/components/ga4/EnhancedEcommerce/header"; import {Footer} from "@/components/ga4/EnhancedEcommerce/footer"; -import {LineItem} from "@/components/ga4/EnhancedEcommerce/line-item"; import {StoreContext} from '@/components/ga4/EnhancedEcommerce/store-context'; import {collapseColumn, emptyStateContainer, emptyStateHeading, grandTotal, imageHeader, labelColumn, productHeader, summary, table, title, totals, wrap,} from "./cart.module.css" @@ -80,9 +79,6 @@ export default (props: Props) => { - {lineItems.map((item) => ( - - ))} From c4f3c3f079fccd42d36faffedf93efc3f3b4e818 Mon Sep 17 00:00:00 2001 From: ikuleshov Date: Mon, 13 Jan 2025 10:29:46 +0000 Subject: [PATCH 7/7] screen_view & ad_impression are no longer reserved event names --- .../schemas/eventTypes/eventDefinitions.ts | 2 -- src/components/ga4/EventBuilder/event.ts | 30 ------------------- src/components/ga4/EventBuilder/types.ts | 2 -- 3 files changed, 34 deletions(-) diff --git a/src/components/ga4/EventBuilder/ValidateEvent/schemas/eventTypes/eventDefinitions.ts b/src/components/ga4/EventBuilder/ValidateEvent/schemas/eventTypes/eventDefinitions.ts index 65a1024e7..920c1212d 100644 --- a/src/components/ga4/EventBuilder/ValidateEvent/schemas/eventTypes/eventDefinitions.ts +++ b/src/components/ga4/EventBuilder/ValidateEvent/schemas/eventTypes/eventDefinitions.ts @@ -1,13 +1,11 @@ // Event and required property mapping export const eventDefinitions = { - "ad_impression": [], "add_payment_info": ["value", "items"], "add_shipping_info": ["value", "items"], "add_to_cart": ["value", "items"], "add_to_wishlist": ["value", "items"], "begin_checkout": ["value", "items"], - "campaign_details": [], "earn_virtual_currency": [], "generate_lead": ["value"], "join_group": [], diff --git a/src/components/ga4/EventBuilder/event.ts b/src/components/ga4/EventBuilder/event.ts index 5704422b4..eb2ac1816 100644 --- a/src/components/ga4/EventBuilder/event.ts +++ b/src/components/ga4/EventBuilder/event.ts @@ -50,19 +50,6 @@ const eventFor = ( const custom_event = eventFor(EventType.CustomEvent, [Category.Custom], [], []) -const ad_impression = eventFor( - EventType.AdImpression, - [Category.AllApps], - [ - stringParam("ad_platform", "MoPub"), - stringParam("ad_source", "AdColony"), - stringParam("ad_format", "Banner"), - stringParam("ad_unit_name", "Banner_03"), - stringParam("currency", "USD"), - numberParam("value", 3.99), - ] -) - const add_payment_info = eventFor( EventType.AddPaymentInfo, [Category.RetailEcommerce], @@ -172,19 +159,6 @@ const begin_checkout = eventFor( ] ) -const campaign_details = eventFor( - EventType.CampaignDetails, - [Category.AllApps], - [ - stringParam("campaign_id", "SUMMER_FUN"), - stringParam("campaign", "Summer_fun"), - stringParam("source", "google"), - stringParam("medium", "cpc"), - stringParam("term", "summer+travel"), - stringParam("content", "logolink"), - ] -) - const earn_virtual_currency = eventFor( EventType.EarnVirtualCurrency, [Category.AllApps], @@ -524,8 +498,6 @@ export const suggestedEventFor = (eventType: EventType): Event2 => { case EventType.CustomEvent: return custom_event - case EventType.AdImpression: - return ad_impression case EventType.AddPaymentInfo: return add_payment_info case EventType.AddShippingInfo: @@ -536,8 +508,6 @@ export const suggestedEventFor = (eventType: EventType): Event2 => { return add_to_wishlist case EventType.BeginCheckout: return begin_checkout - case EventType.CampaignDetails: - return campaign_details case EventType.EarnVirtualCurrency: return earn_virtual_currency case EventType.GenerateLead: diff --git a/src/components/ga4/EventBuilder/types.ts b/src/components/ga4/EventBuilder/types.ts index f8d108ea8..b853bd720 100644 --- a/src/components/ga4/EventBuilder/types.ts +++ b/src/components/ga4/EventBuilder/types.ts @@ -28,13 +28,11 @@ export enum Category { export enum EventType { CustomEvent = "custom_event", - AdImpression = "ad_impression", AddPaymentInfo = "add_payment_info", AddShippingInfo = "add_shipping_info", AddToCart = "add_to_cart", AddToWishlist = "add_to_wishlist", BeginCheckout = "begin_checkout", - CampaignDetails = "campaign_details", EarnVirtualCurrency = "earn_virtual_currency", GenerateLead = "generate_lead", JoinGroup = "join_group",