0 Replies
      Latest reply on Nov 3, 2016 1:04 PM by creativecat
      creativecat Level 1 Level 1 (0 points)

        I'm using the following code to track Search Ad attribution. Half the time though, "iad-attribution" is true, yet there's no "iad-campaign-name" or "iad-conversion-date". If there's no date or campaign, does that mean that the install should not be attributed or that it just couldn't get this information? From what I can tell "iad-attribution" is incorrectly set to true becuase right now I've attributed more installs to Apple Search then the Apple dashboard shows. However, if I only look at attribution that include a "iad-campaign-name" then it's about 77% of Apple reported downloads (meaning ~23% may have not have opened the app) which seems closer to correct.

         

        
            [[ADClient sharedClient] requestAttributionDetailsWithBlock:^(NSDictionary *attributionDetails, NSError *error) {
                if (error.code == ADClientErrorLimitAdTracking) {
                    /
                    /
                } else if (error) {
                    /
                    /
                    return;
                } else {
                    /
                    __block NSDictionary *iAdCampaignInfo = (NSDictionary *)attributionDetails[@"Version3.1"];
                    __block BOOL foundVersionKey = YES;
             
                    /
                    if(!iAdCampaignInfo) {
                        [((NSDictionary *)attributionDetails) enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) {
                            foundVersionKey = [[key lowercaseString] hasPrefix:@"version"];
                            if(foundVersionKey) {
                                iAdCampaignInfo = (NSDictionary *)obj;
                            }
                            *stop = foundVersionKey;
                        }];
                    }
             
                    /
                    if (foundVersionKey) {
                        if (iAdCampaignInfo[@"iad-attribution"]) {
                            BOOL isIadAttributed = [iAdCampaignInfo[@"iad-attribution"] boolValue];
                            /
                            if (isIadAttributed) {
                                if ([self isFakeIadAttribution:iAdCampaignInfo]) {
                                    // fake ad
                                } else {
                                    NSLog(@"Valid iAd campaign attribution info detected: %@", iAdCampaignInfo);
        
                                    if (iAdCampaignInfo[@"iad-campaign-name"]) {
                                      // track campaign
                                    }
                              
                                    if (iAdCampaignInfo[@"iad-conversion-date"]) {
                                       // track install date
                                    }
                                }
                            }
                        }
                    }
                }
            }];
        
        - (BOOL)isFakeIadAttribution:(NSDictionary *)dict {
            NSString *fakeId = @"1234567890";
            return [(NSString *)dict[@"iad-campaign-id"] isEqualToString:fakeId]
            || [(NSString *)dict[@"iad-lineitem-id"] isEqualToString:fakeId]
            || [(NSString *)dict[@"iad-creative-id"] isEqualToString:fakeId];
        }