PHP Form/mail()/phpmailer Issue – Godaddy Hosting
March 7, 2021
If you are using Google Tag Manager code (GTAG) and would like to track phone/mail clicks then use the below code:
Step 1: Go to your header/footer file of your website
Step 2: Paste the code as it is and make sure you are using gtag in website
Step 3: Verify once if your phone and email links have ANCHOR TAG (a href="mailto:" / a href="tel:" )
Note: You can click once and verify in your google analytics account in Events (Goal Conversions)
// For Email Tracking
jQuery('a[href^="mailto:"]').click(function(){
var mailto=jQuery(this).attr('href');
gtag('event', 'Mail', {
'event_category': 'Mail',
'event_label': 'Mail'
});
});
// For Phone number Tracking
jQuery('a[href^="tel:"]').click(function(){
var ctc=jQuery(this).attr('href');
gtag('event', 'Call', {
'event_category': 'Phone',
'event_label': 'Phone'
});
});