HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityLog In

Removing specific statistics

This topic explains how to use the APIs to remove data from statistics, and to prevent statistics that contain certain formats from being stored with Optimizely Search & Navigation.

How it works

You can use the APIs to remove statistical data and to prevent the addition of personally identifiable information (PII) to the search index. For example, you can prevent data that contains an at sign (@) from being indexed.

This feature involves the following APIs.

MethodDescriptionSample
StatisticsGetGDPRSearch GDPR data from statistics. Use to get statistics items that match a query pattern.
An extension method of IStatisticsClient.
public static GDPRQueryResult StatisticGetGDPR(this IStatisticsClient client, string query)
StatisticsDeleteGDPRDelete GDPR data from statistics. Used to delete all statistics items that match the query pattern.
An extension method of IStatisticsClient.
public static GDPRDeleteResult StatisticDeleteGDPR(this IStatisticsClient client, string query)

In addition, you can use these APIs to prevent PII data from appearing in search query results.

ITrackSanitizerPatternRepository

MethodDescriptionSample
AddAdd patterns to storage which, in turn, are used to prevent PII data from search query.string Add(TrackSanitizerPattern pattern)
void Add(IEnumerable<TrackSanitizerPattern> patterns)
GetGet pattern by Pattern Id from storageTrackSanitizerPattern Get(string patternId)
GetAllGet all patterns from storageIEnumerable<TrackSanitizerPattern> GetAll()
UpdateUpdate existing pattern(s)string Update(TrackSanitizerPattern pattern)

void Update(IEnumerable<TrackSanitizerPattern> patterns)
DeleteDelete pattern by Id from storagevoid Delete(string patternId)
DeleteAllDelete all patterns from storagevoid DeleteAll()

See also Preventing indexing of PII data.

Examples

To retrieve and remove PII data from statistics, you can search for a range of data:

  • Email including domain name, for example "[email protected]"
  • Full name, for example "John Doe"

You can prevent sensitive data in a custom search query from being saved to the statistics using a predefined pattern.

public class Sample
  {
    protected IClient _client;
    protected IStatisticsClient _statisticsClient;
    protected ITrackSanitizerPatternRepository _trackSaniziterRepository;
    public Sample(IClient client)
      {
        _client = client;
        _trackSaniziterRepository = new DefaultTrackSanitizerRepository(_client);
      } 
    // Setting and add sanitizer patterns.
    _trackSaniziterRepository.Add(new List<TrackSanitizerPattern>
      {
        new TrackSanitizerPattern 
          { 
            PatternString = "admin", 
            PatternType = TrackSanitizerFilterType.PlainText 
          },
        new TrackSanitizerPattern 
          { 
            PatternString = "email",
            PatternType = TrackSanitizerFilterType.PlainText 
          },
        new TrackSanitizerPattern 
          { 
            PatternString = "*@mail.com", 
            PatternType = TrackSanitizerFilterType.Wildcard 
          },
        new TrackSanitizerPattern 
          {
            PatternString = "1#1", 
            PatternType = TrackSanitizerFilterType.Wildcard 
          },
        new TrackSanitizerPattern 
          { 
            PatternString = "c[a-e]ll", 
            PatternType = TrackSanitizerFilterType.Wildcard 
          },
        new TrackSanitizerPattern 
          { 
            PatternString = @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", 
            PatternType = TrackSanitizerFilterType.Regex 
          }
      });
 
    // Doing Tracking behavior
    var result = _client
      .UnifiedSearchFor(@"email admin [email protected] [email protected]
        [email protected] ball bell bill 121 131 141 call cell")
      .StatisticsTrack()
      .GetResult();
 
    // Try to get GDPR data by keyword matched sanitize pattern.
    var response = _statisticsClient.GetGDPR("@mail.com", x => { });
  };​

When using a wildcard pattern, review these Microsoft wildcard samples.

Search, filter, and delete PII data

Use statistics#Search_filter_delete, see Preventing indexing of PII data how to install a sample and verify the deletion.


Did this page help you?