Skip to content

Commit 8f49600

Browse files
committed
refactor: add Google Tag Manager
1 parent f4bd70e commit 8f49600

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/layout/DefaultLayout.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
import React from 'react'
1+
import React, { useEffect } from 'react'
2+
import { useLocation } from 'react-router-dom'
3+
24
import { AppContent, AppSidebar, AppFooter, AppHeader } from '../components/index'
35

46
const DefaultLayout = () => {
7+
const location = useLocation()
8+
9+
useEffect(() => {
10+
// Google Tag Manager
11+
window.dataLayer = window.dataLayer || []
12+
window.dataLayer.push({
13+
event: 'pageview',
14+
page_location: window.location.href,
15+
})
16+
}, [location])
17+
518
return (
619
<div>
720
<AppSidebar />

0 commit comments

Comments
 (0)