@68publishers/amp-client
Version:
JS Client for 68publishers/amp
15 lines (10 loc) • 465 B
JavaScript
let warned = false;
export default (eventName, eventArgs) => {
if (!('gtag' in window) || 'function' !== typeof window.gtag) {
!warned && console.warn('Unable to send metrics to Google Analytics because the function gtag() does not occur in the window.');
warned = true;
return;
}
Object.keys(eventArgs).forEach((key) => (eventArgs[key] === null) && delete eventArgs[key]);
window.gtag('event', eventName, eventArgs);
};