Skip to content

Commit

Permalink
표준 이벤트로 변경.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminKim committed Aug 13, 2024
1 parent 1105dfe commit 32b7f2d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions assets/js/analytics.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
document.addEventListener('DOMContentLoaded', function () {
function trackButtonClick(buttonId, eventName) {
function trackButtonClick(buttonId, eventLabel) {
const button = document.getElementById(buttonId);

if (button) {
button.addEventListener('click', function () {
const pageUrl = window.location.href;
const pageTitle = document.title;

gtag('event', eventName, {
gtag('event', 'share', {
'event_category': 'Button',
'event_label': eventLabel,
'value': 1,
'page_title': pageTitle,
'page_url': pageUrl
Expand All @@ -16,9 +18,9 @@ document.addEventListener('DOMContentLoaded', function () {
}
}

trackButtonClick('share-button', 'share_button_click');
trackButtonClick('rss-button', 'rss_button_click');
trackButtonClick('awesome-rss-button', 'awesome_button_click');
trackButtonClick('coffee-app', 'coffee_button_click');
trackButtonClick('jeho-email', 'email_button_click');
trackButtonClick('share-button', 'Share Button');
trackButtonClick('rss-button', 'Rss Button');
trackButtonClick('awesome-rss-button', 'Awesome Rss Button');
trackButtonClick('jeho-email', 'Jeho Email Button');
trackButtonClick('coffee-app', 'CoffeeApp Button');
});

0 comments on commit 32b7f2d

Please sign in to comment.