1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-08-11 11:43:58 +02:00

Add support for custom labels in ga

This commit is contained in:
Kamran Ahmed
2023-05-10 01:18:23 +01:00
parent 1c67068eab
commit 5ccfa654ec

View File

@@ -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`,
}); });
}} }}
> >