Skip to content

Commit

Permalink
Fix ga event is not sent if gtag is present
Browse files Browse the repository at this point in the history
  • Loading branch information
pacotole committed Feb 11, 2020
1 parent fe6d031 commit 879f6df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions public/js/whatsappme.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@
'eventLabel': link
});
}
if (typeof gtag == 'function') {
// Send custom event (Global Site Tag - gtag.js)
gtag('event', 'click', {
'event_category': 'WhatsAppMe',
'event_label': link,
'transport_type': 'beacon'
});
} else if (typeof ga == 'function' && typeof ga.getAll == 'function') {
if (typeof ga == 'function' && typeof ga.getAll == 'function') {
// Send custom event (Universal Analtics - analytics.js)
ga('set', 'transport', 'beacon');
var trackers = ga.getAll();
trackers.forEach(function (tracker) {
tracker.send("event", 'WhatsAppMe', 'click', link);
});
} else if (typeof gtag == 'function') {
// Send custom event (Global Site Tag - gtag.js)
gtag('event', 'click', {
'event_category': 'WhatsAppMe',
'event_label': link,
'transport_type': 'beacon'
});
}
if (typeof fbq == 'function') {
// Send Facebook Pixel custom event
Expand Down
2 changes: 1 addition & 1 deletion public/js/whatsappme.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 879f6df

Please sign in to comment.