【问题标题】:How to create new property in google analytics using c# code如何使用 C# 代码在谷歌分析中创建新属性
【发布时间】:2018-12-05 11:18:15
【问题描述】:

我们可以在谷歌分析中手动创建属性。但我想通过编写 c# 代码来创建新属性。我不知道我需要使用哪个 API。请帮助我使用 c# 代码创建属性。

【问题讨论】:

    标签: c# google-analytics google-analytics-api google-api-console


    【解决方案1】:

    views.insert 方法将允许您插入新的 provile / 视图。

     /// Create a new view (profile). 
            /// Documentation https://developers.google.com/analytics/v3/reference/profiles/insert
            /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
            /// </summary>
            /// <param name="service">Authenticated Analytics service.</param>  
            /// <param name="accountId">Account ID to create the view (profile) for.</param>
            /// <param name="webPropertyId">Web property ID to create the view (profile) for.</param>
            /// <param name="body">A valid Analytics v3 body.</param>
            /// <returns>ProfileResponse</returns>
            public static Profile Insert(AnalyticsService service, string accountId, string webPropertyId, Profile body)
            {
                try
                {
                    // Initial validation.
                    if (service == null)
                        throw new ArgumentNullException("service");
                    if (body == null)
                        throw new ArgumentNullException("body");
                    if (accountId == null)
                        throw new ArgumentNullException(accountId);
                    if (webPropertyId == null)
                        throw new ArgumentNullException(webPropertyId);
    
                    // Make the request.
                    return service.Profiles.Insert(body, accountId, webPropertyId).Execute();
                }
                catch (Exception ex)
                {
                    throw new Exception("Request Profiles.Insert failed.", ex);
                }
            }
    

    ProfilesSampleManagement 窃取的代码

    【讨论】:

      猜你喜欢
      • 2011-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多