In Fathom Analytics, you can track when someone performs a certain action, or reaches a certain goal. This could be clicking on a button, submitting a form, signing up for a newsletter or visiting a specific page.
I want to track when people renew their membership and make it all the way to the confirmation page after paying.
Here’s the specific bit of code.
if (context === document && window.location.pathname === '/confirmation/renewal') {
fathom.trackEvent('renewal completed');
}
I’m checking the pathname to ensure this only fires if the user is on the confirmation/renewal page.
This is a Drupal site, so this code is in the following Drupal behaviour.
(function ($, Drupal, once) {
'use strict';
Drupal.behaviors.msocfathom = {
attach: function attach(context, settings) {
// Track page load conversion for renewal completed
if (context === document && window.location.pathname === '/confirmation/renewal') {
fathom.trackEvent('renewal completed');
}
}
};
})(jQuery, Drupal, once);
Ideas on running an independent consulting business, thoughtful productivity and the art of running successful sprints
No spam, no sharing to third party. Only you and me.