バージョン選択

フォーラム

メニュー

オンライン状況

51 人のユーザが現在オンラインです。 (39 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 51
もっと...

サイト内検索

質問 > その他 > GA4で

その他

新規スレッドを追加する

スレッド表示 | 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
cusmix
投稿日時: 2023/6/11 12:05
対応状況: −−−
半人前
登録日: 2022/4/23
居住地:
投稿: 12
GA4で
▼テンプレート
[EC-CUBE] EC-CUBEのバージョン、新規インストールかアップデートか、等
[レンタルサーバ] Xserver
[OS] windows10
[ブラウザ] 114.0.5735.110(Official Build) (64 ビット)
[カスタマイズの有無] ブロックに下記のコードをを入れて、全てのページのヘッダーに設置しています。

コード
{% if app.request.get('_route') == 'product_list' %}
    {# 商品一覧 #}
    <script>
        dataLayer.push({ecommerce: null});
        // GA4
        dataLayer.push({
            'event': 'view_item_list',
            'ecommerce': {
                'items': [
                    {% for Product in pagination %}
                    {
                        'item_name': '{{ Product.name }}',
                        'item_id': '{{ Product.getCodeMin ? Product.getCodeMin : Product.id }}',
                        'price': '{{ Product.getPrice02IncTaxMin }}',
                    }{% if not loop.last %},{% endif %}
                    {% endfor %}
                ]
            }
        });

        // UA
        dataLayer.push({
            'ecommerce': {
                'currencyCode': 'JPY',
                'impressions': [
                    {% for Product in pagination %}
                    {
                        'name': '{{ Product.name }}',
                        'id': '{{ Product.getCodeMin ? Product.getCodeMin : Product.id }}',
                        'price': '{{ Product.getPrice02IncTaxMin }}',
                    }{% if not loop.last %},{% endif %}
                    {% endfor %}
                ]
            }
        });
    </script>

{% elseif app.request.get('_route') == 'product_detail' %}
    {# 商品詳細 #}
    <script>
        dataLayer.push({ecommerce: null}); 
        // GA4
        dataLayer.push({
            'event': 'view_item',
            'ecommerce': {
                'items': [{
                    'item_name': '{{ Product.name }}',
                    'item_id': '{{ Product.getCodeMin ? Product.getCodeMin : Product.id }}',
                    'price': '{{ Product.getPrice02IncTaxMin }}',
                    'item_category': '{% for ProductCategory in Product.ProductCategories %}{% for Category in ProductCategory.Category.path %}{% if ( Category.parent is not null ) %}{{ Category.Parent.name }}:{{ Category.name }}{% endif %}{% endfor %}{% endfor %}',
                    'quantity': '1'
                }]
            }
        });

        // UA
        dataLayer.push({
            'ecommerce': {
                'detail': {
                    'products': [{
                        'name': '{{ Product.name }}',
                        'id': '{{ Product.getCodeMin ? Product.getCodeMin : Product.id }}',
                        'price': '{{ Product.getPrice02IncTaxMin }}',
                        'category': '{% for ProductCategory in Product.ProductCategories %}{% for Category in ProductCategory.Category.path %}{% if ( Category.parent is not null ) %}{{ Category.Parent.name }}:{{ Category.name }}{% endif %}{% endfor %}{% endfor %}',
                    }]
                }
            }
        });
    </script>

{% elseif app.request.get('_route') == 'cart' %}
    {# カートに追加 #}
    <script>
        dataLayer.push({ecommerce: null});
        // GA4
        dataLayer.push({
            'event': 'add_to_cart',
            'ecommerce': {
                'items': [
                    {% for CartItem in Cart.CartItems %}
                    {% set ProductClass = CartItem.Object %}
                    {% set Product = ProductClass.Product %}
                    {
                        'item_name': '{{ Product.name }}',
                        'item_id': '{{ Product.getCodeMin ? Product.getCodeMin : Product.id }}',
                        'price': '{{ Product.getPrice02IncTaxMin }}'
                    }{% if not loop.last %},{% endif %}
                    {% endfor %}
                ]
            }
        });

        // UA
        dataLayer.push({
            'event': 'addToCart',
            'ecommerce': {
                'currencyCode': 'JPY',
                'add': {
                    'products': [
                        {% for CartItem in Cart.CartItems %}
                        {% set ProductClass = CartItem.Object %}
                        {% set Product = ProductClass.Product %}
                        {
                            'name': '{{ Product.name }}',
                            'id': '{{ Product.getCodeMin ? Product.getCodeMin : Product.id }}',
                            'price': '{{ Product.getPrice02IncTaxMin }}',
                            'quantity': {{ CartItem.quantity }}
                        }{% if not loop.last %},{% endif %}
                        {% endfor %}
                    ]
                }
            }
        });
    </script>

{% elseif app.request.get('_route') == 'shopping_complete' %}
    {# 購入完了 #}

    {% if Order.id %}
        <script>
            dataLayer.push({ecommerce: null});
            // GA4
            dataLayer.push({
                'event': 'purchase',
                'ecommerce': {
                    'transaction_id': '{{ Order.id }}',
                    'affiliation': '{{ BaseInfo.shop_name }}',
                    'value': '{{ Order.subtotal }}',
                    'tax': '{{ Order.tax }}',
                    'shipping': '{{ Order.delivery_fee_total }}',
                    'currency': 'JPY',
                    'items': [
                        {% for OrderDetail in Order.OrderDetails %}
                        {
                            'item_name': '{{ OrderDetail.product_name }}',
                            'item_id': '{{ OrderDetail.product_code ? OrderDetail.product_code : OrderDetail.product.id }}',
                            'price': '{{ OrderDetail.price_inc_tax }}',
                            'item_category': '{% for ProductCategory in OrderDetail.Product.ProductCategories %}{% for Category in ProductCategory.Category.path %}{% if ( Category.parent is not null ) %}{{ Category.Parent.name }}:{{ Category.name }}{% endif %}{% endfor %}{% endfor %}',
                            'quantity': {{ OrderDetail.quantity }}
                        }{% if not loop.last %},{% endif %}
                        {% endfor %}
                    ]
                }
            });

            // UA
            dataLayer.push({
                'ecommerce': {
                    'purchase': {
                        'actionField': {
                            'id': '{{ Order.id }}',
                            'affiliation': '{{ BaseInfo.shop_name }}',
                            'revenue': '{{ Order.subtotal }}',
                            'tax': '{{ Order.tax }}',
                            'shipping': '{{ Order.delivery_fee_total }}'
                        },
                        'products': [
                            {% for OrderDetail in Order.OrderDetails %}
                            {
                                'name': '{{ OrderDetail.product_name }}',
                                'id': '{{ OrderDetail.product_code ? OrderDetail.product_code : OrderDetail.product.id }}',
                                'price': '{{ OrderDetail.price_inc_tax }}',
                                'category': '{% for ProductCategory in OrderDetail.Product.ProductCategories %}{% for Category in ProductCategory.Category.path %}{% if ( Category.parent is not null ) %}{{ Category.Parent.name }}:{{ Category.name }}{% endif %}{% endfor %}{% endfor %}',
                                'quantity': {{ OrderDetail.quantity }}
                            }{% if not loop.last %},{% endif %}
                            {% endfor %}
                        ]
                    }
                }
            });
        </script>
    {% endif %}

{% endif %}


[現象] タグマネージャーでフィルタがEventが『add_to_cart』に等しい、というトリガーを作成。

新たなタグで、イベント名が{{Event}}で、トリガーは上記のトリガーを設定したタグを設置。

しかし、発火しません。

また、GA4のフォルダの中にある、e コマース購入数: アイテム名にも表示されません。

どのようにしたら、カートに追加された商品数をGA4で確認することができるようになるでしょうか?
mcontact
投稿日時: 2023/6/12 17:08
対応状況: −−−
登録日: 2022/1/22
居住地:
投稿: 1295
Re: GA4で
https://www.ec-cube.net/event/detail.php?event_id=363


----------------
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
EC-CUBEインテグレートパートナー【ゴールド】ランク
M&I Works
URL: https://miworks.biz/
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

スレッド表示 | 新しいものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は88,873名です
総投稿数は110,000件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2313
5
umebius
2085
6
yuh
1819
7
h_tanaka
1646
8
red
1570
9
mcontact
1295
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
799
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.