Last active
November 16, 2019 04:06
-
-
Save syuji-higa/72b9f345b9d9225d0d1bfc87a9702e5d to your computer and use it in GitHub Desktop.
Nuxt.js - GTM
This file contains hidden or 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
export const pushGtmEvent = (event = 'nuxt.historyChange) => { | |
if(window.dataLayer) { | |
setTimeout(() => { | |
window.dataLayer.push({ event }) | |
}, 500) | |
} | |
} |
This file contains hidden or 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
<script> | |
import pushGtmEvent from '~/utils/gtm' | |
export default { | |
mounted() { | |
this.$nextTick(() => { | |
pushGtmEvent() | |
}) | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment