gtag多个自定义维度 [英] gtag multiple custom dimensions

查看:235
本文介绍了gtag多个自定义维度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上搜索了解决方案,以向Google Analytics(分析)发送多个自定义维度.

I searched the web for the solution to send multiple custom dimensions to google analytics.

旧标签ga易于配置,如下所示:

the old tag ga was easy to configure like so :

ga('create', 'UA-ID', 'auto');

    ga('set', 'dimension1', value1);
    ga('set', 'dimension2', value2);
    ga('set', 'dimension3', value3);
    ga('send', 'pageview');

这将发送所有3个自定义维度.

this would send all of the 3 custom dimensions.

新gtag.js出现了问题,我尝试了多种配置多个自定义维度的方法. 文档显示了如何配置1个自定义维度:

the problem occurs with the new gtag.js I tried lots of ways to configure multiple custom dimensions. the documentation shows how to configure 1 custom dimension as so :

gtag('config', 'UA-ID', {
 'custom_map': {'dimension1': 'value'}
});
gtag('event','eventname', {'valuename':value});

[适用于1维],但我不知道如何发送多个自定义维.

This works [for 1 dimension] but I can't figure out how to send multiple custom dimensions.

[尝试发送具有2个维度字段的对象,尝试复制具有不同维度的config自定义地图-没用]

[tried sending the object with 2 fields of dimension , tried to duplicate the config custom map with different dimensions - it didn't work]

有什么想法吗?

推荐答案

您仍然可以使用旧版代码,但必须将其发送到JSON中,例如:

You can still use the Legacy version of the code but you have to send it inside a JSON instead, as the example

--Option I-- 
-- Set Option -- 

gtag( 'set' , {'dimension1' : "yxz"} );                      // Set a Single Element
gtag( 'set' , {'dimension2' : "abc",'dimension3' : "123"} ); // Set multiple Elements
gtag('config', 'UA-1-1');                             // Pageview with 3 cd

--Option II--
-- Map Function--


gtag('config', 'UA-ID', {
 'custom_map': {'dimension1': 'value',
                'dimension2': 'value2',
                'dimension3': 'value3'}
});
gtag('event','eventname', {'value1':"1",'value2':"2",'value3':"3"});

这篇关于gtag多个自定义维度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆