Encodes parameter values into the Utme parameter format used by Google Analytics for events and custom variables.
Beispiel #1
0
        /// <summary>
        /// Create a Utme-encoded parameter string containing the details of a given EventActivity.
        /// </summary>
        /// <param name="event">Event to encode.</param>
        /// <returns>Utme-encoded parameter string representing this EventActivity.</returns>
        private static string ToEventParameter(EventActivity @event)
        {
            var queryValue = UtmeEncoder.Encode("5", @event.Category, @event.Action, @event.Label);

            if (@event.Value.HasValue)
            {
                queryValue += "(" + UtmeEncoder.EscapeValue(@event.Value.Value.ToString(CultureInfo.InvariantCulture)) + ")";
            }

            return(queryValue);
        }
Beispiel #2
0
        /// <summary>
        /// Obtain the key/value pairs for a TimedEventActivity.
        /// </summary>
        /// <param name="timedEvent">TimedEventActivity to turn into key/value pairs.</param>
        /// <returns>Key/value pairs representing this TimedEventActivity.</returns>
        internal static IEnumerable <KeyValuePair <string, string> > GetParameters(TimedEventActivity timedEvent)
        {
            yield return(KeyValuePair.Create("utmt", "event"));

            yield return(KeyValuePair.Create("utme", UtmeEncoder.Encode(timedEvent)));
        }
 /// <summary>
 /// Encode custom variables into a single parameter string.
 /// </summary>
 /// <param name="customVariables">Custom variables to encode.</param>
 /// <returns>Encoded custom variables.</returns>
 internal static string EncodeCustomVariables(ScopedCustomVariableSlot[] customVariables)
 {
     return(UtmeEncoder.Encode("8", customVariables.Select(c => c == null ? null : c.Variable.Name).ToArray())
            + UtmeEncoder.Encode("9", customVariables.Select(c => c == null ? null : c.Variable.Value).ToArray())
            + UtmeEncoder.Encode("11", customVariables.Select(c => c == null ? null : GetScopeIdentity(c.Scope)).ToArray()));
 }