JS - GA trigger event function

0 votes
167 views
added Mar 7, 2022 in JSX by lcjr First Warrant Officer (11,780 points)
import Router from 'next/router';

render() {
    const brandclick = e => { //function name
      e.preventDefault();
      window.dataLayer.push({
        event: 'mortgagecta', //event name
        url: Router.asPath, //imported from router above
        pageType: 'listingpage',
      });
      window.open('https://google.com', '_blank');
    };
    return ( 
      <div className="brand" onClick={e => brandclick(e)}> //event function
        <img             src="/images/banner.jpg"
          className="img-fluid"
          alt="Brand cick"
        />
      </div> 
    );
  }

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...