Capture Customer Keys
Typically, you would want to link a customers' profile to one or more keys either when they successfully log in to your app, or at another moment in time when an identifier is available.
To help you identify your customers you can send these keys to an Interaction or as properties to a base Touchpoint using the SDK public methods.
In our use case example, we want to capture a customer's email address as a customer key when they log in to our mobile app.
Step 1: Create a "Login Successful" Interaction Point
In MXO create an Interaction Point to track successful logins to your app.
For more information, see Creating and Managing Interaction Points.
Example Details
Field | Description |
---|---|
Name | Login Successful Interaction |
Path | /loginSuccessful |
Step 2: Create a new "Email Address" Key Attribute
Create a new key attribute that will store the value captured for a customer's email address following a successful login.
For more information, see Creating and Managing Data Attributes.
Example Details
Field | Description |
---|---|
Name | Email Address |
Description | Optional |
Customer Attribute Type | Text |
Key Attribute | Yes |
API Name | email_address |
How should MXO store this value? | As provided |
Step 3: Create an Attribute Capture Point
Create a new URL /API Parameters Attribute Capture Point to capture a customer's email address when they log in to your app.
For more information, see Creating a URI/API Parameter Attribute Capture Point.
Example Details
Field | Description |
---|---|
Name | Email Capture |
URI/API Parameter to capture from | emailAddress |
Store as: | Existing Customer Attribute |
Select Customer Attribute | Email Address (Text) |
Step 4: Publish Your Changes
In MXO, publish your changes to push them to your live environment.
Step 5: Send Customer Keys to an Interaction
Use the Mobile SDK to send a customer's email address to MXO when they log in to your app successfully.
You can send the email address parameter using the public sendInteraction
method.
This enables you to capture both the login activity and email address (to use as a key) for a customer, and allows you to recognize your app users.
Send Customer Keys using the iOS SDK
To send an Interaction request with properties using the iOS SDK, see the full instructions in the iOS documentation.
Example
You can send the email address parameter when a user successfully logs in into your app using the SDK public method, as follows:
let properties = ["emailAddress":"user@email.com"]
if let interaction = try? MXOInteraction(withString: "/loginSuccessful") {
do {
try MedalliaMXO.sendInteraction(request: MXOInteractionRequest { builder in
builder.interaction = interaction
builder.properties = properties
})
} catch {
print("Error sending an interaction with properties: \(error.localizedDescription)")
}
}
NSError *error;
NSDictionary *properties = @{@"emailAddress":@"user@email.com"};
__block MXOInteraction *interaction = [MXOInteraction initWithString:@"/loginSuccessful" error:&error];
[MedalliaMXO sendInteraction:[MXOInteractionRequest initWithBuilder:^(MXOInteractionRequestBuilder * _Nonnull builder) {
builder.interaction = interaction;
builder.properties = properties;
}] error:&error];
Send Customer Keys using the Android SDK
To send an Interaction request with properties using the Android SDK, see the full instructions in the Android documentation.
Example
You can send the email address parameter when a user successfully logs in into your app using the SDK public method, as follows:
import com.medallia.mxo.interactions.MXOInteraction
import com.medallia.mxo.mxoSendInteraction
import java.net.URI
scope.launch {
mxoSendInteraction {
interaction = MXOInteraction(URI("/loginSuccessful"))
properties = mapOf("emailAddress" to "user@email.com")
}
}
import com.medallia.mxo.MedalliaMXO;
import com.medallia.mxo.interactions.MXOInteraction;
import com.medallia.mxo.interactions.MXOInteractionRequest;
import java.net.URI;
final Map<String, String> properties = new HashMap<>();
properties.put("emailAddress","user@email.com");
final MXOInteractionRequest sendInteractionRequest = new MXOInteractionRequest.Builder()
.interaction(new MXOInteraction(URI.create("/loginSuccessful")))
.properties(properties)
.build();
try {
MedalliaMXO.sendInteraction(sendInteractionRequest);
} catch (Exception e) {
e.printStackTrace();
}