Skip to content
This repository was archived by the owner on Apr 6, 2025. It is now read-only.

pirxpilot/ga-event

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ga

Google Analytics event tracking Use instead of ga component to track pages and events

Installation

TBD

API

Activate Google Analytics on the page and track page

require('ga')("UA-XXXX-X");

Alternatively you can define GA property ID as a data attribute of document body

<body data-ga-property-id="UA-XXXX-X">

You can track events by declaring event properties in HTML

<a href="/link"
  data-ga-category="Videos"
  data-ga-action="Play"
  data-ga-label="Baby's First Birthday" >
  Click here
</a>

You only need to set ga-category. ga-action defaults to click and ga-label, ga-value, and ga-noninteractive are all optional in Google Analytics.

ga-event registers DOM event handler that will generate trackEvent call whenever item is clicked.

Check test/index.html for example.

License

MIT

About

Google Analytics component with event tracking

Resources

License

Stars

2 stars

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors