You can use Sailthru's Site Personalization Manager (SPM) to send personalized content to your users across channels - Onsite, Email and Mobile.
On mobile this is dead simple, and similar to implementing our JavaScript Client Library in Custom Mode.
This guide assumes that you've set up SPM on the web.
Tracking Content Metrics
Content Metrics overview
When providing personalized content, tracking a user's interests is of great importance - it means that the user will get recommended things that they actually care about making them more likely to convert through to your recommended content. SPM provides three different types of tracking metrics:
- A pageview is an indication that a user has seen a given item of content's detail view - for example, a page for a certain product in an online store, or a full news article in a news site.
- An impression is a reasonable assumption that a user has seen a given piece of content - maybe they've scrolled past it in a list view, or seen it in a "Recommended" panel on another content item.
- A click is exactly what it sounds like: it means that a user has clicked - or in this case tapped - on a given piece of content to learn more. This usually, but not always, means that a user will now transition to that content's detail view.
Implementing Content Metrics
Tracking Pageviews
Sailthru's trackPageview
method should be passed a URL corresponding to the web URL of the content being viewed, as well as an array of tags. If the tags array is empty or null, Sailthru will use any tags for this page stored in your content library - otherwise, those stored tags will be overridden by any passed to trackPageview
.
ArrayList<String> tags = new ArrayList(Arrays.asList("blazer", "beige", "tan"));
URI contentUrl = URI.create("https://varickandvandam.com/products/1153128");
Carnival.trackPageview(contentUrl, tags, new Carnival.TrackHandler() {
@Override
public void onSuccess() {
// We're good
}
@Override
public void onFailure(Error error) {
// Handle errors here
}
});
// Alternatively, if we don't mind too much if the track request fails, use a null handler:
Carnival.trackPageview(contentUrl, tags, null)
let tags = ["blazer", "beige", "tan"]
let contentUrl = URL(string: "https://varickandvandam.com/products/1153128")
Carnival.trackPageview(withUrl: contentUrl, andTags: tags) { (errorOrNil) in
if let error = errorOrnil {
print(error)
return
}
// Track success! 🙌
}
// Alternatively, if we don't mind too much if the track request fails, just omit the block:
Carnival.trackPageview(withUrl: contentUrl, andTags: tags)
NSArray<NSString*> *tags = @[@"blazer", @"beige", @"tan"];
NSURL *contentUrl = [NSURL URLWithString:@"https://varickandvandam.com/products/1153128"];
[Carnival trackPageviewWithUrl: contentUrl, andTags: tags, andResponse: ^(NSError *error) {
if (error) {
// Handle error case
} else {
// Things went right, hooray!
}
}];
// Alternatively, if we don't mind too much if the track request fails, use a nil block:
[Carnival trackPageviewWithUrl: contentUrl, andTags: tags, andResponse: nil]
We recommend tracking pageviews as views within your app are being initialized. For example, on Android, you might call trackPageview
in a Fragment's onCreateView
method, whereas on iOS you might place it in a ViewController's viewDidAppear
method.
Tracking Impressions
An impression should be tracked when a section of recommended content is seen by a user. Sailthru's trackImpression
method takes a SPM Section ID as its first argument, and a list of URLs corresponding to the URLs of the items in the section.
ArrayList<URI> urls = new ArrayList(Arrays.asList(
URI.create("https://varickandvandam.com/products/1153128"),
URI.create("https://varickandvandam.com/products/1098230"),
URI.create("https://varickandvandam.com/products/1078590")
));
String sectionID = "a very real section ID";
Carnival.trackImpression(sectionID, urls, new Carnival.TrackHandler() {
@Override
public void onSuccess() {
// We're good
}
@Override
public void onFailure(Error error) {
// Handle errors here
}
});
// Alternatively, if we don't mind too much if the track request fails, use a null handler:
Carnival.trackImpression(sectionID, urls, null)
let urls = [
URL("https://varickandvandam.com/products/1153128"),
URL("https://varickandvandam.com/products/1098230"),
URL("https://varickandvandam.com/products/1078590")
]
let sectionID = "a very real section ID"
Carnival.trackImpression(withSection: sectionID, andUrls: urls) { (errorOrNil) in
if let error = errorOrnil {
print(error)
return
}
// Track success! 🙌
}
// Alternatively, if we don't mind too much if the track request fails, just omit the block:
Carnival.trackImpression(withSection: sectionID, andUrls: urls)
NSArray<NSURL*> *urls = @[
[NSURL URLWithString:@"https://varickandvandam.com/products/1153128"],
[NSURL URLWithString:@"https://varickandvandam.com/products/1098230"],
[NSURL URLWithString:@"https://varickandvandam.com/products/1078590"]
];
NSString *sectionID = @"A very real section ID";
[Carnival trackImpressionWithSession: sectionID, andUrls: urls, andResponse: ^(NSError *error) {
if (error) {
// Handle error case
} else {
// Things went right, hooray!
}
}];
// Alternatively, if we don't mind too much if the track request fails, use a nil block:
[Carnival trackImpressionWithSession: sectionID, andUrls: urls, andResponse: nil]
We recommend that you call trackImpression
as a recommendation section enters the user's viewport on their device. On Android, you might do this by attaching an OnChildAttachStateChangeListener to a RecyclerView, and placing a call to trackImpression
in the body of its onChildViewAttachedToWindow
method. On iOS, you might consider calling trackImpression
in the UITableViewDelegate
method tableView:willDisplayCell.
Tracking Clicks
A click should be tracked when a user clicks on an item present in a section of recommendations, passing the section ID as the first argument, and the URL of the item being navigated to as the second argument.
URI url = URI.create("https://varickandvandam.com/products/1078590");
String sectionID = "a very real section ID";
Carnival.trackClick(sectionID, url, new Carnival.TrackHandler() {
@Override
public void onSuccess() {
// We're good
}
@Override
public void onFailure(Error error) {
// Handle errors here
}
});
// Alternatively, if we don't mind too much if the track request fails, use a null handler:
Carnival.trackImpression(sectionID, url, null)
let url = URL("https://varickandvandam.com/products/1153128")
let sectionID = "a very real section ID"
Carnival.trackClick(withSection: sectionID, andUrl: url) { (errorOrNil) in
if let error = errorOrnil {
print(error)
return
}
// Track success! 🙌
}
// Alternatively, if we don't mind too much if the track request fails, just omit the block:
Carnival.trackClick(withSection: sectionID, andUrl: url)
NSURL *url = [NSURL URLWithString:@"https://varickandvandam.com/products/1153128"];
NSString *sectionID = @"A very real section ID";
[Carnival trackClickWithSession: sectionID, andUrl: url, andResponse: ^(NSError *error) {
if (error) {
// Handle error case
} else {
// Things went right, hooray!
}
}];
// Alternatively, if we don't mind too much if the track request fails, use a nil block:
[Carnival trackClickWithSession: sectionID, andUrl: url, andResponse: nil]