Skip to content

Instantly share code, notes, and snippets.

@gjreasoner
Last active October 8, 2018 16:47
Show Gist options
  • Save gjreasoner/829bc3ea31e19575a68a93139517f7f0 to your computer and use it in GitHub Desktop.
Save gjreasoner/829bc3ea31e19575a68a93139517f7f0 to your computer and use it in GitHub Desktop.
Vanilla js
function convert(name) {
if (!ga) return;
var tracker = ga.getAll()[0];
tracker.send("event", name);
}
document.addEventListener('wpcf7submit', function (event) {
convert(event.detail.contactFormId);
});
document.querySelector('a[href^="tel:"]').onclick = function () {
convert('clicked-call')
};
document.querySelector('a[href^="mailto:"]').onclick = function () {
convert('email-link')
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment