-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from polywrap/rihp/goal-tracking
feat: track user goals with google analytics
- Loading branch information
Showing
5 changed files
with
102 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
interface Window { | ||
gtag: any; | ||
} | ||
declare var window: Window; | ||
|
||
export const trackMessageSent = (message: string) => { | ||
try { | ||
if (window.gtag) { // Check if gtag is initialized | ||
window.gtag('event', 'message_sent', { | ||
'event_category': 'Chat', | ||
'event_label': 'GOALS', | ||
'value': message // The actual message content | ||
}); | ||
console.log('GA event sent'); | ||
} else { | ||
console.log('GA not initialized'); | ||
} | ||
} catch (error) { | ||
console.log('Error sending GA event:', error); | ||
} | ||
}; | ||
|