https://ogaeng.com/godomall-ga4-ecommerce-setting/
* 코드 삽입 부분
{ # footer } 위에
* !!주의!!
outline/_header.html 의 경우
{=customHeader} 바로 위에 적용
http://gdadmin.u2store.co.kr/design/design_page_edit.php?designPageId=outline/_header.html
http://gdadmin.u2store.co.kr/mobile/design_page_edit.php?designPageId=outline/_header.html
<!-- for GTM - 2022-12-05 -->
<script type="text/javascript">
var loginCheck = '{=gd_is_login()}';
if (loginCheck == '1'){
dataLayer = [{
'mall_user_id': '{=gSess.memNo}'
}];
}
</script>
<!-- // for GTM - 2022-12-05 -->
http://gdadmin.u2store.co.kr/design/design_page_edit.php?designPageId=goods/goods_view.html //PC
http://gdadmin.u2store.co.kr/mobile/design_page_edit.php?designPageId=goods/goods_view.html //모바일
<!-- for GTM - 2022-12-05 -->
<script type="text/javascript">
dataLayer.push({
'event': 'detail',
'goodsInfo': [{
'item_id': '{goodsView.goodsNo}',
'item_name': '{=goodsView['goodsNm']}',
'price': '{=gd_isset(goodsView['goodsPrice'],0)}'
}]
});
</script>
<script type="text/javascript">
var addToCart = function () {
dataLayer.push({
'event': 'addToCart',
'goodsInfo': [{
'item_id': '{goodsView.goodsNo}',
'item_name': '{=goodsView['goodsNm']}',
'price': '{=gd_isset(goodsView['goodsPrice'],0)}',
'quantity': goodsTotalCnt
}]
});
}
$('#cartBtn').click(addToCart);
</script>
<!-- // for GTM - 2022-12-05 -->
http://gdadmin.u2store.co.kr/design/design_page_edit.php?designPageId=order/order.html
http://gdadmin.u2store.co.kr/mobile/design_page_edit.php?designPageId=order/order.html
<!-- for GTM - 2022-12-05 -->
<script type="text/javascript">
var goodsInfo = [
<!--{ @ cartInfo }-->
<!--{ @ .value_ }-->
<!--{ @ ..value_ }-->
{
'item_id': '{=...goodsNo}',
'item_name': '{=...goodsNm}',
'quantity': {=...goodsCnt},
'price': {=...price['goodsPrice']}
},
<!--{ / }-->
<!--{ / }-->
<!--{ / }-->
];
dataLayer.push({
'event': 'checkout',
'goodsInfo': goodsInfo
});
</script>
<!-- // for GTM - 2022-12-05 -->
http://gdadmin.u2store.co.kr/design/design_page_edit.php?designPageId=order/order_end.html
http://gdadmin.u2store.co.kr/mobile/design_page_edit.php?designPageId=order/order_end.html
<!-- for GTM - 2022-12-05 -->
<script type="text/javascript">
var txInfo = {
'transactionId': '{orderInfo.orderNo}',
'totalRevenue': {=orderInfo.settlePrice},
'shippingFee': {=gd_isset(orderInfo.totalDeliveryCharge)},
'firstOrder': '{=orderInfo.firstSaleFl}'
};
var goodsInfo = [
<!--{ @ orderInfo.goods }-->
{
'item_id': '{=.goodsNo}',
'item_name': '{=.goodsNm}',
'quantity': {=.goodsCnt},
'price': {=.goodsPrice}
},
<!--{ / }-->
];
dataLayer.push({
'event': 'purchase',
'txInfo': txInfo,
'goodsInfo': goodsInfo
});
</script>
<!-- // for GTM - 2022-12-05 -->
for test
var txInfo = {
'transactionId': 'test-transactionId',
'totalRevenue': 0,
'shippingFee': 0,
'firstOrder': 'N'
};
var goodsInfo = [
{
'item_id': 'test-item_id',
'item_name': 'test-item_name',
'quantity': 1,
'price': 1000
},
];
dataLayer.push({
'event': 'purchase',
'txInfo': txInfo,
'goodsInfo': goodsInfo
});