Add support for custom labels in ga

pull/3907/head
Kamran Ahmed 2 years ago
parent 1c67068eab
commit 5ccfa654ec
  1. 10
      src/components/PageSponsor.tsx

@ -7,6 +7,7 @@ import { sponsorHidden } from '../stores/page';
export type PageSponsorType = { export type PageSponsorType = {
company: string; company: string;
description: string; description: string;
gaLabel: string;
imageUrl: string; imageUrl: string;
pageUrl: string; pageUrl: string;
title: string; title: string;
@ -49,7 +50,9 @@ export function PageSponsor(props: PageSponsorProps) {
window.fireEvent({ window.fireEvent({
category: 'SponsorImpression', category: 'SponsorImpression',
action: `${response.sponsor?.company} Impression`, action: `${response.sponsor?.company} Impression`,
label: `${gaPageIdentifier} / ${response.sponsor?.company} Link`, label:
response.sponsor.gaLabel ||
`${gaPageIdentifier} / ${response.sponsor?.company} Link`,
}); });
}; };
@ -61,7 +64,8 @@ export function PageSponsor(props: PageSponsorProps) {
return null; return null;
} }
const { url, title, imageUrl, description, company, pageUrl } = sponsor; const { url, title, imageUrl, description, company, gaLabel, pageUrl } =
sponsor;
return ( return (
<a <a
@ -73,7 +77,7 @@ export function PageSponsor(props: PageSponsorProps) {
window.fireEvent({ window.fireEvent({
category: 'SponsorClick', category: 'SponsorClick',
action: `${company} Redirect`, action: `${company} Redirect`,
label: `${gaPageIdentifier} / ${company} Link`, label: gaLabel || `${gaPageIdentifier} / ${company} Link`,
}); });
}} }}
> >

Loading…
Cancel
Save