Mixpanel

Automatic integration

Smartlook can be automatically integrated into Mixpanel like this:

Mixpanel.sharedInstance(withToken: "YOUR_MIXPANEL_API_TOKEN")

let smartlookConfiguration = Smartlook.Configuration.configuration(key: "YOUR_SMARTLOOK_API_KEY")
if let mixpanelInstance = Mixpanel.sharedInstance() {
    smartlookConfiguration.enableIntegrations = [ Smartlook.MixpanelIntegration(integrationWith: mixpanelInstance) ]
}

Smartlook.setupAndStartRecording(configuration: smartlookConfiguration)
[Mixpanel sharedInstanceWithToken:@"YOUR_MIXPANEL_API_KEY"];

SLSetupConfiguration *configuration = [SLSetupConfiguration configurationWithKey:@"YOUR_SMARTLOOK_API_KEY"];
configuration.enableIntegrations = @[ [SLMixpanelIntegration alloc] initIntegrationWith:[Mixpanel sharedInstance]] ];

[Smartlook setupAndStartRecordingWithConfiguration:configuration];

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

1459

Manual integration

Smartlook can be easily integrated into Mixpanel using Notifications:

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

NotificationCenter.default.addObserver(forName: Smartlook.dashboardVisitorURLChanged, object: nil, queue: nil) { (note) in
    if let currentVisitorUrl = Smartlook.getDashboardVisitorURL() {
        mixpanel?.people.set(property: "smartlook_visitor_url", to: currentVisitorUrl)
    }
}
[[NSNotificationCenter defaultCenter] addObserverForName:SLDashboardSessionURLChangedNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
    NSURL *currentSessionURL = [Smartlook getDashboardSessionURLWithCurrentTimestamp:NO];
    if (currentSessionURL != nil) {
      [mixpanel track:@"Smartlook session URL" properties:@{ @"session_url" : currentSessionURL}];
    }
}];

[[NSNotificationCenter defaultCenter] addObserverForName:SLDashboardVisitorURLChangedNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
    NSURL *currentVisitorURL = [Smartlook getDashboardVisitorURL];
    if (currentVisitorURL != nil) {
      [mixpanel.people set:@"smartlook_visitor_url" to:currentVisitorURL.absoluteString];
    }
}];

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