Beispiel #1
0
        public void LinkFilterToView(string viewId, string filterId)
        {
            var filterRef = new FilterRef()
            {
                Id = filterId
            };

            var body = new ProfileFilterLink()
            {
                FilterRef = filterRef
            };

            var insertRequest = _analyticsService.Management.ProfileFilterLinks.Insert(body, Analytic.AccountId, Analytic.PropertyId, viewId);
            var response      = insertRequest.Execute();
        }
        /// <summary>
        /// Create a new profile filter link.
        /// Documentation https://developers.google.com/analytics/v3/reference/profileFilterLinks/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 profile filter link for.</param>
        /// <param name="webPropertyId">Web property Id to create profile filter link for.</param>
        /// <param name="profileId">Profile ID to create filter link for.</param>
        /// <param name="body">A valid analytics v3 body.</param>
        /// <returns>ProfileFilterLinkResponse</returns>
        public static ProfileFilterLink Insert(analyticsService service, string accountId, string webPropertyId, string profileId, ProfileFilterLink 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);
                }
                if (profileId == null)
                {
                    throw new ArgumentNullException(profileId);
                }

                // Make the request.
                return(service.ProfileFilterLinks.Insert(body, accountId, webPropertyId, profileId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request ProfileFilterLinks.Insert failed.", ex);
            }
        }