아무거나

여러개의 GTM을 적용하여 dataLayer.push 전송방법 본문

IT/개발관련툴

여러개의 GTM을 적용하여 dataLayer.push 전송방법

전봉근 2021. 11. 24. 09:20
반응형
// GTM을 각각 코드값이 다르게 선언하며 dataLayer 정의를 따로 적용(clickAnalysisDataLayer, ga4DataLayer) (JSP 예시)
<!-- Google Tag Manager [GTM_CLICK_ANALYSIS_ID] -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','clickAnalysisDataLayer','${Const.GTM_CLICK_ANALYSIS_ID}');</script>
<!-- End Google Tag Manager [GTM_CLICK_ANALYSIS_ID] -->

<!-- Google Tag Manager [GTM_GA4_ID] -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','ga4DataLayer','${Const.GTM_GA4_ID}');</script>
<!-- End Google Tag Manager [GTM_GA4_ID] -->
반응형
Comments