Amplitude

Automatic integration

Smartlook can be automatically integrated into Amplitude using the following:

Amplitude.instance()?.initializeApiKey("YOUR_AMPLITUDE_API_KEY")

let smartlookConfiguration = Smartlook.Configuration.configuration(key: "YOUR_SMARTLOOK_API_KEY")
smartlookConfiguration.enableIntegrations = [ Smartlook.AmplitudeIntegration(integrationWith: Amplitude.instance()) ]
    
Smartlook.setupAndStartRecording(configuration: smartlookConfiguration)
[[Amplitude instance] initializeApiKey:@"YOUR_AMPLITUDE_API_KEY"];

SLSetupConfiguration *configuration = [SLSetupConfiguration configurationWithKey:@"YOUR_SMARTLOOK_API_KEY"];
configuration.enableIntegrations = @[ [[SLAmplitudeIntegration alloc] initIntegrationWith:[Amplitude instance]] ];

[Smartlook setupAndStartRecordingWithConfiguration:configuration];

The Smartlook visitor URL will be added as a new property called the Smartlook visitor dashboard URL into a Amplitude user.

12591259

Manual integration

Smartlook can be easily integrated into Amplitude using Notifications:

NotificationCenter.default.addObserver(forName: Smartlook.dashboardSessionURLChanged, object: nil, queue: nil) { (note) in
  if let currentSessionUrl = Smartlook.getDashboardSessionURL(withCurrentTimestamp: false) {
    Amplitude.instance()?.logEvent("Smartlook session URL", withEventProperties: [ "session_url": currentSessionUrl])
  }
}

NotificationCenter.default.addObserver(forName: Smartlook.dashboardVisitorURLChanged, object: nil, queue: nil) { (note) in
  if let currentVisitorUrlString = Smartlook.getDashboardVisitorURL()?.absoluteString {
    let identify = AMPIdentify().add("smartlook_visitor_url", value: currentVisitorUrlString as NSString)
    Amplitude.instance()?.identify(identify)
  }
}
[[NSNotificationCenter defaultCenter] addObserverForName:SLDashboardSessionURLChangedNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
  NSURL *currentSessionURL = [Smartlook getDashboardSessionURLWithCurrentTimestamp:NO];
  if (currentSessionURL != nil) {
      [[Amplitude instance] logEvent:@"Smartlook session URL" withEventProperties:@{ @"session_url" : currentSessionURL}];
  }
}];

[[NSNotificationCenter defaultCenter] addObserverForName:SLDashboardVisitorURLChangedNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
  NSURL *currentVisitorURL = [Smartlook getDashboardVisitorURL];
  if (currentVisitorURL != nil) {
    AMPIdentify *identify = [[AMPIdentify identify] add:@"smartlook_visitor_url" value:currentVisitorURL];
    [[Amplitude instance] identify:identify];
  }
}];

Full Amplitude documentation with examples can be found on the official website.