Exemple #1
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long activityGroupId = long.Parse(_T("INSERT_ACTIVITY_GROUP_ID_HERE"));
            long profileId       = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            String activityName = _T("INSERT_ACTIVITY_NAME_HERE");
            String url          = _T("INSERT_EXPECTED_URL_HERE");

            // Set floodlight activity structure.
            FloodlightActivity activity = new FloodlightActivity();

            activity.CountingMethod            = "STANDARD_COUNTING";
            activity.Name                      = activityName;
            activity.FloodlightActivityGroupId = activityGroupId;
            activity.ExpectedUrl               = url;

            // Create the floodlight tag activity.
            FloodlightActivity result =
                service.FloodlightActivities.Insert(activity, profileId).Execute();

            // Display new floodlight activity ID.
            if (result != null)
            {
                Console.WriteLine("Floodlight activity with ID {0} was created.", result.Id);
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long floodlightActivityId = long.Parse(_T("INSERT_FLOODLIGHT_ACTIVITY_ID_HERE"));
            long profileId            = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string conversionMobileId = _T("INSERT_CONVERSION_MOBILE_ID_HERE");

            // Generate a timestamp in milliseconds since Unix epoch.
            TimeSpan timeStamp = DateTime.UtcNow - new DateTime(1970, 1, 1);
            long     currentTimeInMilliseconds = (long)timeStamp.TotalMilliseconds;

            // Find the Floodlight configuration ID based on the provided activity ID.
            FloodlightActivity floodlightActivity =
                service.FloodlightActivities.Get(profileId, floodlightActivityId).Execute();
            long floodlightConfigurationId = (long)floodlightActivity.FloodlightConfigurationId;

            // Create the conversion.
            Conversion conversion = new Conversion();

            conversion.MobileDeviceId            = conversionMobileId;
            conversion.FloodlightActivityId      = floodlightActivityId;
            conversion.FloodlightConfigurationId = floodlightConfigurationId;
            conversion.Ordinal         = currentTimeInMilliseconds.ToString();
            conversion.TimestampMicros = currentTimeInMilliseconds * 1000;

            // Insert the conversion.
            ConversionsBatchInsertRequest request = new ConversionsBatchInsertRequest();

            request.Conversions = new List <Conversion>()
            {
                conversion
            };

            ConversionsBatchInsertResponse response =
                service.Conversions.Batchinsert(request, profileId).Execute();

            // Handle the batchinsert response.
            if (!response.HasFailures.Value)
            {
                Console.WriteLine("Successfully inserted conversion for mobile device ID {0}.",
                                  conversionMobileId);
            }
            else
            {
                Console.WriteLine("Error(s) inserting conversion for mobile device ID {0}:",
                                  conversionMobileId);

                ConversionStatus status = response.Status[0];
                foreach (ConversionError error in status.Errors)
                {
                    Console.WriteLine("\t[{0}]: {1}", error.Code, error.Message);
                }
            }
        }
    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long activityGroupId = long.Parse(_T("INSERT_ACTIVITY_GROUP_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

      String activityName = _T("INSERT_ACTIVITY_NAME_HERE");
      String url = _T("INSERT_EXPECTED_URL_HERE");

      // Set floodlight activity structure.
      FloodlightActivity activity = new FloodlightActivity();
      activity.CountingMethod = "STANDARD_COUNTING";
      activity.Name = activityName;
      activity.FloodlightActivityGroupId = activityGroupId;
      activity.ExpectedUrl = url;

      // Create the floodlight tag activity.
      FloodlightActivity result =
          service.FloodlightActivities.Insert(activity, profileId).Execute();

      // Display new floodlight activity ID.
      if (result != null) {
        Console.WriteLine("Floodlight activity with ID {0} was created.", result.Id);
      }
    }
        /// <summary>
        /// Updates an existing floodlight activity.
        /// Documentation https://developers.google.com/dfareporting/v2.8/reference/floodlightActivities/update
        /// 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 Dfareporting service.</param>
        /// <param name="profileId">User profile ID associated with this request.</param>
        /// <param name="body">A valid Dfareporting v2.8 body.</param>
        /// <returns>FloodlightActivityResponse</returns>
        public static FloodlightActivity Update(DfareportingService service, string profileId, FloodlightActivity body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (profileId == null)
                {
                    throw new ArgumentNullException(profileId);
                }

                // Make the request.
                return(service.FloodlightActivities.Update(body, profileId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request FloodlightActivities.Update failed.", ex);
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long encryptionEntityId   = long.Parse(_T("INSERT_ENCRYPTION_ENTITY_TYPE"));
            long floodlightActivityId = long.Parse(_T("INSERT_FLOODLIGHT_ACTIVITY_ID_HERE"));
            long profileId            = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string conversionUserId     = _T("INSERT_CONVERSION_USER_ID_HERE");
            string encryptionEntityType = _T("INSERT_ENCRYPTION_ENTITY_TYPE_HERE");
            string encryptionSource     = _T("INSERT_ENCRYPTION_SOURCE_HERE");

            // [START create_conversion] MOE:strip_line
            // Generate a timestamp in milliseconds since Unix epoch.
            TimeSpan timeSpan = DateTime.UtcNow - new DateTime(1970, 1, 1);
            long     currentTimeInMilliseconds = (long)timeSpan.TotalMilliseconds;

            // Find the Floodlight configuration ID based on the provided activity ID.
            FloodlightActivity floodlightActivity =
                service.FloodlightActivities.Get(profileId, floodlightActivityId).Execute();
            long floodlightConfigurationId = (long)floodlightActivity.FloodlightConfigurationId;

            // Create the conversion.
            Conversion conversion = new Conversion();

            conversion.EncryptedUserId           = conversionUserId;
            conversion.FloodlightActivityId      = floodlightActivityId;
            conversion.FloodlightConfigurationId = floodlightConfigurationId;
            conversion.Ordinal         = currentTimeInMilliseconds.ToString();
            conversion.TimestampMicros = currentTimeInMilliseconds * 1000;
            // [END create_conversion] MOE:strip_line

            // [START create_encryption_info] MOE:strip_line
            // Create the encryption info.
            EncryptionInfo encryptionInfo = new EncryptionInfo();

            encryptionInfo.EncryptionEntityId   = encryptionEntityId;
            encryptionInfo.EncryptionEntityType = encryptionEntityType;
            encryptionInfo.EncryptionSource     = encryptionSource;
            // [END create_encryption_info] MOE:strip_line

            // [START insert_conversion] MOE:strip_line
            // Insert the conversion.
            ConversionsBatchInsertRequest request = new ConversionsBatchInsertRequest();

            request.Conversions = new List <Conversion>()
            {
                conversion
            };
            request.EncryptionInfo = encryptionInfo;

            ConversionsBatchInsertResponse response =
                service.Conversions.Batchinsert(request, profileId).Execute();

            // [END insert_conversion] MOE:strip_line

            // [START process_response] MOE:strip_line
            // Handle the batchinsert response.
            if (!response.HasFailures.Value)
            {
                Console.WriteLine("Successfully inserted conversion for encrypted user ID {0}.",
                                  conversionUserId);
            }
            else
            {
                Console.WriteLine("Error(s) inserting conversion for encrypted user ID {0}:",
                                  conversionUserId);

                ConversionStatus status = response.Status[0];
                foreach (ConversionError error in status.Errors)
                {
                    Console.WriteLine("\t[{0}]: {1}", error.Code, error.Message);
                }
            }
            // [END process_response] MOE:strip_line
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            // Values that identify the existing conversion.
            long   floodlightActivityId = long.Parse(_T("INSERT_FLOODLIGHT_ACTIVITY_ID_HERE"));
            long   conversionTimestamp  = long.Parse(_T("INSERT_CONVERSION_TIMESTAMP_HERE"));
            string conversionOrdinal    = _T("INSERT_CONVERSION_ORDINAL_VALUE_HERE");
            string conversionMobileId   = _T("INSERT_CONVERSION_MOBILE_ID_HERE");

            // Values to update for the specified conversion.
            long newQuantity = long.Parse(_T("INSERT_NEW_CONVERSION_QUANTITY_HERE"));
            long newValue    = long.Parse(_T("INSERT_NEW_CONVERSION_VALUE_HERE"));

            // Find the Floodlight configuration ID based on the provided activity ID.
            FloodlightActivity floodlightActivity =
                service.FloodlightActivities.Get(profileId, floodlightActivityId).Execute();
            long floodlightConfigurationId = (long)floodlightActivity.FloodlightConfigurationId;

            // Construct the conversion object with values that identify the conversion to update.
            Conversion conversion = new Conversion();

            conversion.MobileDeviceId            = conversionMobileId;
            conversion.FloodlightActivityId      = floodlightActivityId;
            conversion.FloodlightConfigurationId = floodlightConfigurationId;
            conversion.Ordinal         = conversionOrdinal;
            conversion.TimestampMicros = conversionTimestamp;

            // Set the fields to be updated. These fields are required; to preserve a value from the
            // existing conversion, it must be copied over manually.
            conversion.Quantity = newQuantity;
            conversion.Value    = newValue;

            // Update the conversion.
            ConversionsBatchUpdateRequest request = new ConversionsBatchUpdateRequest();

            request.Conversions = new List <Conversion>()
            {
                conversion
            };

            ConversionsBatchUpdateResponse response =
                service.Conversions.Batchupdate(request, profileId).Execute();

            // Handle the batchupdate response.
            if (!response.HasFailures.Value)
            {
                Console.WriteLine("Successfully updated conversion for mobile device ID {0}.",
                                  conversionMobileId);
            }
            else
            {
                Console.WriteLine("Error(s) updating conversion for mobile device ID {0}:",
                                  conversionMobileId);

                ConversionStatus status = response.Status[0];
                foreach (ConversionError error in status.Errors)
                {
                    Console.WriteLine("\t[{0}]: {1}", error.Code, error.Message);
                }
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            // Value that specify how the existing conversion is encrypted.
            long   encryptionEntityId   = long.Parse(_T("INSERT_ENCRYPTION_ENTITY_TYPE"));
            string encryptionEntityType = _T("INSERT_ENCRYPTION_ENTITY_TYPE_HERE");
            string encryptionSource     = _T("INSERT_ENCRYPTION_SOURCE_HERE");

            // Values that identify the existing conversion.
            long   floodlightActivityId = long.Parse(_T("INSERT_FLOODLIGHT_ACTIVITY_ID_HERE"));
            long   conversionTimestamp  = long.Parse(_T("INSERT_CONVERSION_TIMESTAMP_HERE"));
            string conversionOrdinal    = _T("INSERT_CONVERSION_ORDINAL_VALUE_HERE");
            string conversionUserId     = _T("INSERT_CONVERSION_USER_ID_HERE");

            // Values to update for the specified conversion.
            long newQuantity = long.Parse(_T("INSERT_NEW_CONVERSION_QUANTITY_HERE"));
            long newValue    = long.Parse(_T("INSERT_NEW_CONVERSION_VALUE_HERE"));

            // [START create_conversion] MOE:strip_line
            // Find the Floodlight configuration ID based on the provided activity ID.
            FloodlightActivity floodlightActivity =
                service.FloodlightActivities.Get(profileId, floodlightActivityId).Execute();
            long floodlightConfigurationId = (long)floodlightActivity.FloodlightConfigurationId;

            // Construct the conversion object with values that identify the conversion to update.
            Conversion conversion = new Conversion();

            conversion.EncryptedUserId           = conversionUserId;
            conversion.FloodlightActivityId      = floodlightActivityId;
            conversion.FloodlightConfigurationId = floodlightConfigurationId;
            conversion.Ordinal         = conversionOrdinal;
            conversion.TimestampMicros = conversionTimestamp;

            // Set the fields to be updated. These fields are required; to preserve a value from the
            // existing conversion, it must be copied over manually.
            conversion.Quantity = newQuantity;
            conversion.Value    = newValue;
            // [END create_conversion] MOE:strip_line

            // [START create_encryption_info] MOE:strip_line
            // Create the encryption info.
            EncryptionInfo encryptionInfo = new EncryptionInfo();

            encryptionInfo.EncryptionEntityId   = encryptionEntityId;
            encryptionInfo.EncryptionEntityType = encryptionEntityType;
            encryptionInfo.EncryptionSource     = encryptionSource;
            // [END create_encryption_info] MOE:strip_line

            // [START update_conversion] MOE:strip_line
            // Insert the conversion.
            ConversionsBatchUpdateRequest request = new ConversionsBatchUpdateRequest();

            request.Conversions = new List <Conversion>()
            {
                conversion
            };
            request.EncryptionInfo = encryptionInfo;

            ConversionsBatchUpdateResponse response =
                service.Conversions.Batchupdate(request, profileId).Execute();

            // [END update_conversion] MOE:strip_line

            // [START process_response] MOE:strip_line
            // Handle the batchinsert response.
            if (!response.HasFailures.Value)
            {
                Console.WriteLine("Successfully updated conversion for encrypted user ID {0}.",
                                  conversionUserId);
            }
            else
            {
                Console.WriteLine("Error(s) updating conversion for encrypted user ID {0}:",
                                  conversionUserId);

                ConversionStatus status = response.Status[0];
                foreach (ConversionError error in status.Errors)
                {
                    Console.WriteLine("\t[{0}]: {1}", error.Code, error.Message);
                }
            }
            // [END process_response] MOE:strip_line
        }