Skip to content

Commit

Permalink
feat: make trackername optional (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanna0 authored Mar 1, 2021
1 parent ac4ae77 commit 096e3a9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/GoogleAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ export const trackEvent = (
const { ga, guardian } = window;
const trackerName: string | undefined =
guardian.config?.googleAnalytics?.trackers.editorial;
if (typeof ga === 'undefined' || typeof trackerName === 'undefined') {
console.error(
"Can't track GA event - GA library not loaded or no tracker found",
);
if (typeof ga === 'undefined') {
console.error("Can't track GA event - GA library not loaded");
return;
}
const timeSincePageLoad: number = Math.round(window.performance.now());

const send = `${trackerName}.send`;
const send = trackerName ? `${trackerName}.send` : 'send';
window.ga(
send,
'timing',
Expand Down

0 comments on commit 096e3a9

Please sign in to comment.