@@ -204,51 +204,62 @@ - (void)trackConversion:(NSString *)goalIdentifier withValue:(NSNumber *)value {
204
204
205
205
// Check if the goal is already marked.
206
206
for (VWOCampaign *campaign in _campaignList) {
207
- VWOGoal *matchedGoal = [campaign goalForIdentifier: goalIdentifier];
208
- if (matchedGoal) {
209
-
210
- if ([VWOUserDefaults isGoalMarked: matchedGoal inCampaign: campaign]) {
211
- BOOL isEventArchEnabled = [VWOUserDefaults IsEventArchEnabled ];
212
- if (!isEventArchEnabled){
213
- VWOLogDebug (@" Goal '%@ ' already marked and eventArch is not enabled. Will not be marked again" , matchedGoal);
214
- return ;
215
- }
216
- if ([matchedGoal mca ] != -1 ){
217
- // if mca flag != -1, then goal is not triggered multiple times.
218
- VWOLogDebug (@" Goal '%@ ' already marked. Will not be marked again" , matchedGoal);
219
- return ;
207
+ NSMutableArray <VWOGoal *>*matchedGoals = [campaign goalForIdentifier: goalIdentifier];
208
+ if ([matchedGoals count ] == 0 ){
209
+ continue ;
210
+ }
211
+
212
+ for (VWOGoal *matchedGoal in matchedGoals){
213
+ if (matchedGoal) {
214
+
215
+ if ([VWOUserDefaults isGoalMarked: matchedGoal inCampaign: campaign]) {
216
+ BOOL isEventArchEnabled = [VWOUserDefaults IsEventArchEnabled ];
217
+ if (!isEventArchEnabled){
218
+ VWOLogDebug (@" Goal '%@ ' already marked and eventArch is not enabled. Will not be marked again" , matchedGoal);
219
+ return ;
220
+ }
221
+ if ([matchedGoal mca ] != -1 ){
222
+ // if mca flag != -1, then goal is not triggered multiple times.
223
+ VWOLogDebug (@" Goal '%@ ' already marked. Will not be marked again" , matchedGoal);
224
+ return ;
225
+ }
220
226
}
221
227
}
222
228
}
223
229
}
224
230
225
231
// Mark goal(Goal can be present in multiple campaigns
226
232
for (VWOCampaign *campaign in _campaignList) {
227
- VWOGoal *matchedGoal = [campaign goalForIdentifier: goalIdentifier];
228
- if (matchedGoal) {
229
- if ([VWOUserDefaults isTrackingUserForCampaign: campaign]) {
230
- [VWOUserDefaults markGoalConversion: matchedGoal inCampaign: campaign];
231
-
232
- NSURL *url = NULL ;
233
- if ((VWOUserDefaults.IsEventArchEnabled != NULL ) &&
234
- ([VWOUserDefaults.IsEventArchEnabled isEqualToString: EventArchEnabled])){
235
- // for Event based API calls
236
- url = [_vwoURL forMarkingGoalEventArch: matchedGoal
237
- withValue: value
238
- campaign: campaign
239
- dateTime: NSDate .date];
240
- }else {
241
- // for previous version support
242
- url = [_vwoURL forMarkingGoal: matchedGoal
243
- withValue: value
244
- campaign: campaign
245
- dateTime: NSDate .date];
233
+ NSMutableArray <VWOGoal *>*matchedGoals = [campaign goalForIdentifier: goalIdentifier];
234
+ if ([matchedGoals count ] == 0 ){
235
+ continue ;
236
+ }
237
+ for (VWOGoal *matchedGoal in matchedGoals){
238
+ if (matchedGoal) {
239
+ if ([VWOUserDefaults isTrackingUserForCampaign: campaign]) {
240
+ [VWOUserDefaults markGoalConversion: matchedGoal inCampaign: campaign];
241
+
242
+ NSURL *url = NULL ;
243
+ if ((VWOUserDefaults.IsEventArchEnabled != NULL ) &&
244
+ ([VWOUserDefaults.IsEventArchEnabled isEqualToString: EventArchEnabled])){
245
+ // for Event based API calls
246
+ url = [_vwoURL forMarkingGoalEventArch: matchedGoal
247
+ withValue: value
248
+ campaign: campaign
249
+ dateTime: NSDate .date];
250
+ }else {
251
+ // for previous version support
252
+ url = [_vwoURL forMarkingGoal: matchedGoal
253
+ withValue: value
254
+ campaign: campaign
255
+ dateTime: NSDate .date];
256
+ }
257
+
258
+ NSString *description = [NSString stringWithFormat: @" Goal %@ " , matchedGoal];
259
+ [pendingURLQueue enqueue: url maxRetry: 10 description: description];
260
+ } else {
261
+ VWOLogWarning (@" Goal %@ not tracked for %@ as user is not tracked" , matchedGoal, campaign);
246
262
}
247
-
248
- NSString *description = [NSString stringWithFormat: @" Goal %@ " , matchedGoal];
249
- [pendingURLQueue enqueue: url maxRetry: 10 description: description];
250
- } else {
251
- VWOLogWarning (@" Goal %@ not tracked for %@ as user is not tracked" , matchedGoal, campaign);
252
263
}
253
264
}
254
265
}
0 commit comments