Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

google analytics nextjs

npm i -D @types/gtag.js
Comment

google analytics nextjs

export const GA_TRACKING_ID = "<INSERT_TAG_ID>";

// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
export const pageview = (url: URL): void => {
  window.gtag("config", GA_TRACKING_ID, {
    page_path: url,
  });
};

type GTagEvent = {
  action: string;
  category: string;
  label: string;
  value: number;
};

// https://developers.google.com/analytics/devguides/collection/gtagjs/events
export const event = ({ action, category, label, value }: GTagEvent): void => {
  window.gtag("event", action, {
    event_category: category,
    event_label: label,
    value,
  });
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript Program to check if a given year is leap year 
Javascript :: sample promise.all javascript 
Javascript :: private router react v6 
Javascript :: jquerey dropdown button 
Javascript :: do while loop javascript 
Javascript :: var hoisting.js 
Javascript :: node.js 
Javascript :: convert string to array js 
Javascript :: cypress run all files in folder 
Javascript :: template strings in js 
Javascript :: send an email react native 
Javascript :: ArduinoJson.h 
Javascript :: You will need to rewrite or cast the expression. 
Javascript :: destructuring js 
Javascript :: pass array as argument javascript 
Javascript :: javaScript disable submit button until form is fully validated 
Javascript :: react animations 
Javascript :: javascript date timezone 
Javascript :: average javascript 
Javascript :: mongodb rename property 
Javascript :: Check If Object Contains A Function 
Javascript :: Sequelize using javascript 
Javascript :: plus sign javascript 
Javascript :: var 
Javascript :: switch statement 
Javascript :: last item of array js 
Javascript :: javascript function destructuring 
Javascript :: lettre au hasard javascript 
Javascript :: append css file with javascript 
Javascript :: what is javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =