From 182dd71db7aaeed87b774b4e13d2ba0902a38cff Mon Sep 17 00:00:00 2001 From: Lyubov Voloshko Date: Tue, 14 Oct 2025 13:10:19 +0300 Subject: [PATCH] add 7-day-return conversion --- .../src/app/services/connections.service.ts | 37 +++++++++++++++++++ frontend/src/index.saas.html | 20 ++++++++++ 2 files changed, 57 insertions(+) diff --git a/frontend/src/app/services/connections.service.ts b/frontend/src/app/services/connections.service.ts index 572c2f46e..c751fab84 100644 --- a/frontend/src/app/services/connections.service.ts +++ b/frontend/src/app/services/connections.service.ts @@ -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('/connections') .pipe( map(res => { diff --git a/frontend/src/index.saas.html b/frontend/src/index.saas.html index 3b5feb77f..bf019522f 100644 --- a/frontend/src/index.saas.html +++ b/frontend/src/index.saas.html @@ -52,6 +52,26 @@ })(window,document,'script','dataLayer','GTM-W64RBP8'); + + + +