https://github.com/mykeels/ga-click
An alternative to embedding JavaScript in your HTML via `onclick` attributes when working with Google Analytics
https://github.com/mykeels/ga-click
alternative events google-analytics onclick
Last synced: 10 months ago
JSON representation
An alternative to embedding JavaScript in your HTML via `onclick` attributes when working with Google Analytics
- Host: GitHub
- URL: https://github.com/mykeels/ga-click
- Owner: mykeels
- Created: 2017-03-22T22:22:58.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-22T22:29:32.000Z (about 9 years ago)
- Last Synced: 2025-04-03T03:12:12.288Z (about 1 year ago)
- Topics: alternative, events, google-analytics, onclick
- Language: JavaScript
- Size: 4.88 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ga-Click
An alternative to embedding JavaScript in your HTML via `onclick` attributes when working with Google Analytics. Click [here](https://mykeels.github.io/ga-click/) to see demo.
## Getting started
Clone this repository.
Add to and Edit the demo event objects in the `EVENTS` dictionary object in the ga-click.js file.
Each item in the EVENTS object has a Key which is a string that should be in camelCase, and a Value which is an object containing the following properties:
- Label: A string that describes the GA Event to be tracked.
- Action: A function that executes the corresponding GA Command.
Add a reference of your resultant script to your web page!
On each element you need to track add a `ga-click` attribute, and the Label of the event you intend that element to represent. E.g. I could add `ga-click='liked'` to my Like button.
Execute your web page.
You now have the power of Google Analytics without the headaches that inline JavaScript brings.
Enjoy!
### Author(s)
- Ikechi Michael I.