IDictionary <string, string> GetRequiredPayloadData(string hitType, bool isNonInteractive, SessionControl sessionControl)
        {
            var result = new Dictionary <string, string>();

            result.Add("v", "1");
            result.Add("tid", PropertyId);
            result.Add("cid", AnonymousClientId);
            result.Add("an", AppName);
            result.Add("av", AppVersion);
            result.Add("t", hitType);
            if (ScreenName != null)
            {
                result.Add("cd", ScreenName);
            }
            if (isNonInteractive)
            {
                result.Add("ni", "1");
            }
            if (AnonymizeIP)
            {
                result.Add("aip", "1");
            }
            if (sessionControl != SessionControl.None)
            {
                result.Add("sc", sessionControl == SessionControl.Start ? "start" : "end");
            }
            if (ScreenResolution.HasValue)
            {
                result.Add("sr", string.Format("{0}x{1}", ScreenResolution.Value.Width, ScreenResolution.Value.Height));
            }
            if (ViewportSize.HasValue)
            {
                result.Add("vp", string.Format("{0}x{1}", ViewportSize.Value.Width, ViewportSize.Value.Height));
            }
            if (UserLanguage != null)
            {
                result.Add("ul", UserLanguage.ToLowerInvariant());
            }
            if (ScreenColorDepthBits.HasValue)
            {
                result.Add("sd", string.Format("{0}-bits", ScreenColorDepthBits.Value));
            }
            if (DocumentEncoding != null)
            {
                result.Add("de", DocumentEncoding);
            }
            foreach (var dimension in CustomDimensions)
            {
                result.Add(string.Format("cd{0}", dimension.Key), dimension.Value);
            }
            foreach (var metric in CustomMetrics)
            {
                result.Add(string.Format("cm{0}", metric.Key), metric.Value.ToString(CultureInfo.InvariantCulture));
            }
            CustomDimensions.Clear();
            CustomMetrics.Clear();

            return(result);
        }
Beispiel #2
0
        private IDictionary <string, string> GetRequiredPayloadData(string hitType, bool isNonInteractive, SessionControl sessionControl)
        {
            var result = new Dictionary <string, string>();

            result.Add("v", "1");
            result.Add("tid", PropertyId);
            result.Add("cid", AnonymousClientId);
            result.Add("an", AppName);
            result.Add("av", AppVersion);
            result.Add("t", hitType);

            if (AppId != null)
            {
                result.Add("aid", AppId);
            }
            if (AppInstallerId != null)
            {
                result.Add("aiid", AppInstallerId);
            }
            if (ScreenName != null)
            {
                result.Add("cd", ScreenName);
            }
            if (isNonInteractive)
            {
                result.Add("ni", "1");
            }
            if (AnonymizeIP)
            {
                result.Add("aip", "1");
            }
            if (sessionControl != SessionControl.None)
            {
                result.Add("sc", sessionControl == SessionControl.Start ? "start" : "end");
            }
            if (ScreenResolution != null)
            {
                result.Add("sr", string.Format("{0}x{1}", ScreenResolution.Width, ScreenResolution.Height));
            }
            if (ViewportSize != null)
            {
                result.Add("vp", string.Format("{0}x{1}", ViewportSize.Width, ViewportSize.Height));
            }
            if (UserLanguage != null)
            {
                result.Add("ul", UserLanguage);
            }
            if (ScreenColorDepthBits.HasValue)
            {
                result.Add("sd", string.Format("{0}-bits", ScreenColorDepthBits.Value));
            }

            if (CampaignName != null)
            {
                result.Add("cn", CampaignName);
            }
            if (CampaignSource != null)
            {
                result.Add("cs", CampaignSource);
            }
            if (CampaignMedium != null)
            {
                result.Add("cm", CampaignMedium);
            }
            if (CampaignKeyword != null)
            {
                result.Add("ck", CampaignKeyword);
            }
            if (CampaignContent != null)
            {
                result.Add("cc", CampaignContent);
            }
            if (CampaignId != null)
            {
                result.Add("ci", CampaignId);
            }

            // other params available but not usually used for apps
            if (Referrer != null)
            {
                result.Add("dr", Referrer);
            }
            if (DocumentEncoding != null)
            {
                result.Add("de", DocumentEncoding);
            }
            if (GoogleAdWordsId != null)
            {
                result.Add("gclid", GoogleAdWordsId);
            }
            if (GoogleDisplayAdsId != null)
            {
                result.Add("dclid", GoogleDisplayAdsId);
            }
            if (IpOverride != null)
            {
                result.Add("uip", IpOverride);
            }
            if (UserAgentOverride != null)
            {
                result.Add("ua", UserAgentOverride);
            }
            if (DocumentLocationUrl != null)
            {
                result.Add("dl", DocumentLocationUrl);
            }
            if (DocumentHostName != null)
            {
                result.Add("dh", DocumentHostName);
            }
            if (DocumentPath != null)
            {
                result.Add("dp", DocumentPath);
            }
            if (DocumentTitle != null)
            {
                result.Add("dt", DocumentTitle);
            }
            if (LinkId != null)
            {
                result.Add("linkid", LinkId);
            }
            if (ExperimentId != null)
            {
                result.Add("xid", ExperimentId);
            }
            if (ExperimentVariant != null)
            {
                result.Add("xvar", ExperimentVariant);
            }
            if (DataSource != null)
            {
                result.Add("ds", DataSource);
            }
            if (UserId != null)
            {
                result.Add("uid", UserId);
            }
            if (GeographicalId != null)
            {
                result.Add("geoid", GeographicalId);
            }

            foreach (var dimension in CustomDimensions)
            {
                result.Add(string.Format("cd{0}", dimension.Key), dimension.Value);
            }
            foreach (var metric in CustomMetrics)
            {
                result.Add(string.Format("cm{0}", metric.Key), metric.Value.ToString(CultureInfo.InvariantCulture));
            }
            CustomDimensions.Clear();
            CustomMetrics.Clear();

            return(result);
        }