Skip to content

Commit c595166

Browse files
committed
Defer page view
1 parent 2729a9a commit c595166

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/views/layouts/_analytics.html.erb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
<script>
1414
window.dataLayer = window.dataLayer || [];
1515
if (window.gtag) {
16-
gtag('event', 'page_view', {
17-
page_title: document.title,
18-
page_location: window.location.href,
19-
});
16+
setTimeout(() => {
17+
gtag('event', 'page_view', {
18+
page_title: document.title,
19+
page_location: window.location.href,
20+
});
21+
}, 1000);
2022
} else {
2123
function gtag(){dataLayer.push(arguments);}
2224
gtag('consent', 'update', {

0 commit comments

Comments
 (0)