Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions frontend/src/app/services/connections.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,44 @@ export class ConnectionsService {
return connection.title || connection.database;
}

private checkAndSendConversion() {
const now = new Date();
const firstVisitTime = localStorage.getItem('first_visit_time');

if (!firstVisitTime) {
// First visit - record the current date
localStorage.setItem('first_visit_time', now.toISOString());
return;
}

const firstVisit = new Date(firstVisitTime);
const daysDifference = Math.floor((now.getTime() - firstVisit.getTime()) / (1000 * 60 * 60 * 24));

if (daysDifference >= 7) {
const repeatConversionSent = localStorage.getItem('repeat_conversion_sent');

if (!repeatConversionSent) {
localStorage.setItem('repeat_conversion_sent', 'true');

// Send conversion event
if (typeof window !== 'undefined' && (window as any).gtag) {
(window as any).gtag('event', 'conversion', {
'send_to': 'AW-419937947/jqGyCJWo4qobEJv9nsgB',
'value': 1.0,
'currency': 'USD',
'event_callback': () => {
console.log('Conversion event sent successfully');
}
});
}
}
}
}

fetchConnections() {
// Check for first visit and send conversion if needed
this.checkAndSendConversion();

return this._http.get<any>('/connections')
.pipe(
map(res => {
Expand Down
20 changes: 20 additions & 0 deletions frontend/src/index.saas.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@
})(window,document,'script','dataLayer','GTM-W64RBP8');</script>
<!-- End Google Tag Manager -->

<!-- Event snippet for Page view conversion page
In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. -->
<script>
function gtag_report_conversion(url) {
var callback = function () {
if (typeof(url) != 'undefined') {
window.location = url;
}
};
gtag('event', 'conversion', {
'send_to': 'AW-419937947/jqGyCJWo4qobEJv9nsgB',
'value': 1.0,
'currency': 'USD',
'event_callback': callback
});
return false;
}
</script>


<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
Expand Down