【问题标题】:Google analytics, emulate campaign hit serverside谷歌分析,模拟活动命中服务器端
【发布时间】:2019-05-12 12:45:55
【问题描述】:

我参与了一个项目,人们需要链接 + 跟踪访问第三方网站的用户。

他们通过设置将用户引导至第三方网站的重定向页面来做到这一点,同时使用 Google 分析设置跟踪并构建指向重定向页面的活动 URL。

我想通过处理分析服务器端来设置更快的重定向页面。它的速度很好,但为了能够过渡,我需要以某种方式模拟通过他们的传递页面。

我正在使用 asp net core,但这应该是相当滞后的,因为我使用的是 google api

    [HttpGet]
    public RedirectResult Get()
    {
        [...]

        //send official analytics async
        Task.Run(() => SendParametersToGoogle(BuildPageViewUrl(_config["officialAnalyticsId"], _config["officialRedirectUrl"], "TCI", source, medium)));

        return Redirect(_config["redirectUrl"]);
    }

    private static string BuildPageViewUrl(string googleId, string documentLocation, string campaignName, string campaignSource, string campaignMedium)
        => $"v=1&tid={UrlEncode(googleId)}&t=pageview&dl={UrlEncode(documentLocation)}" +
           $"&cn={UrlEncode(campaignName)}&cs={UrlEncode(campaignSource)}&cm={UrlEncode(campaignMedium)}";

    private static void SendParametersToGoogle(string parameters) => HttpClient.PostAsync(new Uri("https://www.google-analytics.com/collect"), new StringContent(parameters, Encoding.ASCII));

我得到了 OK 响应,但事件未显示在 Google Analytics 的 Acquisition->Campaigns->All Campaigns 下。

我已经等待了 3 天,以留出数据处理时间。

有什么想法吗?

【问题讨论】:

    标签: google-analytics measurement-protocol


    【解决方案1】:

    您生成的Measurement Protocol 调用似乎缺少Client IDUser ID。文档根据需要声明其中之一,以识别访问者。

    我不确定,为什么您会收到成功的响应,因为客户端 ID 也被 Hit Builder 工具标记为必填字段:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多