/// <summary> /// Tracks a conversion event for a particular user for a running server-side campaign. /// </summary> /// <param name="userId">User ID which uniquely identifies each user.</param> /// <param name="goalIdentifier">The Goal key to uniquely identify a goal of a server-side campaign.</param> /// <param name="options">Dictionary for passing extra parameters to activate</param> /// <returns> /// A boolean value based on whether the impression was made to the VWO server. /// True, if an impression event is successfully being made to the VWO server for report generation. /// False, If userId provided is not part of campaign or when unexpected error comes and no impression call is made to the VWO server. /// </returns> public Dictionary <string, bool> Track(string userId, string goalIdentifier, Dictionary <string, dynamic> options = null) { if (options == null) { options = new Dictionary <string, dynamic>(); } string goalTypeToTrack = options.ContainsKey("goalTypeToTrack") ? options["goalTypeToTrack"] : null; bool shouldTrackReturningUser = options.ContainsKey("shouldTrackReturningUser") ? options["shouldTrackReturningUser"] : this._shouldTrackReturningUser; goalTypeToTrack = !string.IsNullOrEmpty(goalTypeToTrack) ? goalTypeToTrack : this._goalTypeToTrack != null ? this._goalTypeToTrack : Constants.GoalTypes.ALL; Dictionary <string, bool> result = new Dictionary <string, bool>(); bool campaignFound = false; foreach (BucketedCampaign campaign in this._settings.Campaigns) { foreach (KeyValuePair <string, Goal> goal in campaign.Goals) { if (goal.Key != null && goalIdentifier == goal.Value.Identifier && (goalTypeToTrack == Constants.GoalTypes.ALL || goalTypeToTrack == goal.Value.Type)) { campaignFound = true; result[campaign.Key] = this.Track(campaign.Key, userId, goalIdentifier, options); } } } if (!campaignFound) { LogErrorMessage.NoCampaignForGoalFound(file, goalIdentifier); return(null); } return(result); }