• Google Analytics & Ads 学习笔记 2 (gtag 版本)


    gtag 是用来取代之前的 ga 的

    但其实它底层就是调用 ga 而已. 只是封装了一个上层. 

    1. start up script 

    <script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsId"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag() {
            dataLayer.push(arguments);
        }
        gtag('js', new Date());
        gtag('config', '@googleAnalyticsId', {
            cookie_domain: 'auto',
            transport_type: 'beacon',
            currency: 'MYR',
            send_page_view: false
        });
        gtag('event', 'page_view');
    </script>

    send_page_view 如果没有 set 的话,会自动发一次 page view 哦

    2. custom event

    call 就是 action

    gtag('event', 'call', {
        event_category: 'engagement',
        event_label: 'phone'
    });

    再比如

    gtag('event', 'location', {
        event_category: 'engagement',
        event_label: 'maps'
    });

    3. ecoomerce product list view

    gtag('event', 'view_item_list', {
        items: [{
                name: 'Product 1',
                list_name: 'Category',
                list_position: 1
            },
            {
                name: 'Product 2',
                list_name: 'Category',
                list_position: 2
            },
        ]
    });

    4. product list CTR

    gtag('event', 'select_content', {
        content_type: 'Product',
        items: [{
            name: el.textContent,
            list_name: 'Category',
            list_position: index + 1,
        }]
    });

    5. product detail view

    gtag('event', 'view_item', {
        items: [{
            name: productName,
        }]
    });

    6. add to cart 

    gtag('event', 'add_to_cart', {
        value: 100,
        items: [{
            name: productName,
            price: 100,
            quantity: 1
        }]
    });

    remove from cart

    gtag('event', remove_from_cart, {
        value: 100,
        items: [{
            name: productName,
            price: 100,
            quantity: 1
        }]
    });

    7. checkout

    gtag('event', 'begin_checkout', {
        value: 100,
        checkout_step: 1,
        items: [{
            name: 'Product 1',
            price: 100,
            quantity: 1
        }]
    });

    next step

    gtag('event', 'checkout_progress', {
        value: 100,
        checkout_step: 2,
        items: [{
            name: 'Product 1',
            price: 100,
            quantity: 1
        }]
    });

    next step

    gtag('event', 'checkout_progress', {
        value: 100,
        checkout_step: 3,
        items: [{
            name: 'Product 1',
            price: 100,
            quantity: 1
        }]
    });

    8. purchase

    gtag('event', 'purchase', {
        transaction_id: 'SO-001',
        value: 100,
        shipping: 20,
        items: [{
            name: 'Product 1',
            price: 100,
            quantity: 1
        }]
    });
  • 相关阅读:
    向对象(OO)程序设计
    gVim安装vim-template插件后提示Undefined variable vim_template_subtype/Press ENTER or type command to continue
    基于JQuery easyui,gson的批量新增/修改和删除-servlet版
    Java正则表达式-匹配正负浮点数
    自己写的ORM工具
    秋色园学习测试项目
    把aspx页面生成的cs文件放到其他类库中,以实现对其的封装操作.
    杭州蚂蚁中台技术部-22届应届生-校招实习
    博客园开博
    开发随手记
  • 原文地址:https://www.cnblogs.com/keatkeat/p/14605869.html
Copyright © 2020-2023  润新知