mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Add Google Analytics component
This commit is contained in:
parent
59963d4906
commit
30afc37346
1 changed files with 28 additions and 0 deletions
28
src/components/google-analytics.astro
Normal file
28
src/components/google-analytics.astro
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
|
||||
import { gaMeasurementId } from '~/helpers/constants.js'
|
||||
// const gaMeasurementId = 'G-0WLH5YTTB0'
|
||||
|
||||
---
|
||||
<!-- Set gaMeasurementId so it's available within the browser/window context -->
|
||||
<script
|
||||
type="text/javascript"
|
||||
set:html={ `window.gaMeasurementId = '${ gaMeasurementId }'` }
|
||||
/>
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script
|
||||
type="text/partytown"
|
||||
async
|
||||
src={ `https://www.googletagmanager.com/gtag/js?id=${ gaMeasurementId }` }
|
||||
></script>
|
||||
<script type="text/partytown">
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag () {
|
||||
dataLayer.push(arguments);
|
||||
}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', gaMeasurementId);
|
||||
|
||||
// console.log('I wanna to shake your hand', gaMeasurementId )
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue