Skip to content

Utility Class of tracking <a></a> tag click events by using Google Analyitcs

License

Notifications You must be signed in to change notification settings

tomoyukikashiro/GaTrackingAtagEvent

Repository files navigation

GaTrackingAtagEvent

Build Status

Utility Class of tracking <a></a> tag click events by using Google Analyitcs

Outline

Utility Class of tracking <a></a> tag click events by using Google Analyitcs

Install via bower

  bower install GaTrackingAtagEvent --save

Usage

load this scripts

<!-- load this script -->
<script src="bower_components/GaTrackingAtagEvent/dist/GaTrackingAtagEvent.min.js"></script>

add attribute (data-ga-label) in <a></a> tag which you want to tracking click event by google analytics.

<!-- call ga('send', 'event', 'link', 'click', ${location.pathname}__toppage); -->
<a href="/" data-ga-label="toppage">
<!-- call ga('send', 'event', 'link', 'click', ${location.pathname}__itempage); -->
<a href="/item" data-ga-label="itempage">
<!-- do not tracking click event of this a tag -->
<a href="/page3">

Demo

If you want to check the value which you send to google analyitcs you have to install google analytics debugger in chrome

Google Analytics Screenshot

Notice

  • This script support Universal Analytics (analytics.js)

About

Utility Class of tracking <a></a> tag click events by using Google Analyitcs

Resources

License

Stars

Watchers

Forks

Packages

No packages published