-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Google Analytics component
Add a new component, GoogleAnalytics, to handle the integration of Google Analytics into the application. This component includes the necessary scripts and configuration to track user interactions and page views. This commit also updates the layout.jsx file to import and use the GoogleAnalytics component, adding the Google Analytics tracking code to the application's HTML.
- Loading branch information
Showing
2 changed files
with
26 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Script from "next/script"; | ||
|
||
const GoogleAnalytics = ({ ga_id }) => ( | ||
<> | ||
<Script | ||
async | ||
src={`https://www.googletagmanager.com/gtag/js? | ||
id=${ga_id}`} | ||
></Script> | ||
<Script | ||
id="google-analytics" | ||
dangerouslySetInnerHTML={{ | ||
__html: ` | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
gtag('config', '${ga_id}'); | ||
`, | ||
}} | ||
></Script> | ||
</> | ||
); | ||
export default GoogleAnalytics; |
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