mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
feat: Add GA4 CTA click tracking across all pages
Track clicks on 'Get started free' and 'Request demo' CTAs via gtag events (cta_get_started, cta_request_demo) and GTM dataLayer. This enables GA4 conversion tracking for CTA clicks, which was previously missing (GA audit found zero conversion events). Uses event delegation so it automatically tracks all CTA links including dynamically rendered ones. Added to: homepage, pricing, demo, blog posts, blog list, status page, and industry pages.
This commit is contained in:
@@ -82,6 +82,7 @@
|
||||
|
||||
<%- include('./Partials/BlogCta') -%>
|
||||
<%- include('../footer') -%>
|
||||
<%- include("../Partials/cta-tracking") -%>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
<%- include('./Partials/BlogCta') -%>
|
||||
<%- include('../footer') -%>
|
||||
<%- include("../Partials/cta-tracking") -%>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -720,6 +720,7 @@
|
||||
} catch(e) {}
|
||||
})();
|
||||
</script>
|
||||
<%- include("../Partials/cta-tracking") -%>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
43
Home/Views/Partials/cta-tracking.ejs
Normal file
43
Home/Views/Partials/cta-tracking.ejs
Normal file
@@ -0,0 +1,43 @@
|
||||
<!-- GA4 CTA Click Tracking -->
|
||||
<script>
|
||||
(function() {
|
||||
// Track clicks on all CTA links (register + demo)
|
||||
document.addEventListener('click', function(e) {
|
||||
var link = e.target.closest('a');
|
||||
if (!link) return;
|
||||
|
||||
var href = link.getAttribute('href') || '';
|
||||
var eventName = null;
|
||||
var eventLabel = '';
|
||||
|
||||
if (href.indexOf('/accounts/register') !== -1) {
|
||||
eventName = 'cta_get_started';
|
||||
eventLabel = link.textContent.trim();
|
||||
} else if (href.indexOf('/enterprise/demo') !== -1) {
|
||||
eventName = 'cta_request_demo';
|
||||
eventLabel = link.textContent.trim();
|
||||
}
|
||||
|
||||
if (eventName) {
|
||||
// GA4 via gtag
|
||||
if (typeof gtag !== 'undefined') {
|
||||
gtag('event', eventName, {
|
||||
event_category: 'conversion',
|
||||
event_label: eventLabel,
|
||||
link_url: href
|
||||
});
|
||||
}
|
||||
// GTM dataLayer (backup)
|
||||
if (typeof dataLayer !== 'undefined') {
|
||||
dataLayer.push({
|
||||
event: eventName,
|
||||
eventCategory: 'conversion',
|
||||
eventAction: eventName,
|
||||
eventLabel: eventLabel,
|
||||
linkUrl: href
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
@@ -811,6 +811,7 @@
|
||||
</main>
|
||||
|
||||
<%- include('footer') -%>
|
||||
<%- include("./Partials/cta-tracking") -%>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
<%- include('footer') -%>
|
||||
|
||||
<%- include('./Partials/video-script') -%>
|
||||
<%- include('./Partials/cta-tracking') -%>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
@@ -386,6 +386,7 @@
|
||||
</main>
|
||||
<%- include('../footer') -%>
|
||||
|
||||
<%- include("../Partials/cta-tracking") -%>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -386,6 +386,7 @@
|
||||
</main>
|
||||
<%- include('../footer') -%>
|
||||
|
||||
<%- include("../Partials/cta-tracking") -%>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -385,6 +385,7 @@
|
||||
</main>
|
||||
<%- include('../footer') -%>
|
||||
|
||||
<%- include("../Partials/cta-tracking") -%>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -378,6 +378,7 @@
|
||||
</main>
|
||||
<%- include('../footer') -%>
|
||||
|
||||
<%- include("../Partials/cta-tracking") -%>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -1953,6 +1953,7 @@ Coinbase: "The Times 03/Jan/2009 Chancellor on brink of second bailout for
|
||||
})();
|
||||
</script>
|
||||
|
||||
<%- include("./Partials/cta-tracking") -%>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1350,6 +1350,7 @@
|
||||
})();
|
||||
</script>
|
||||
|
||||
<%- include("./Partials/cta-tracking") -%>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user