コンテンツカード
アプリケーションで使用できるさまざまなデータモデルやカード固有のプロパティなど、Braze SDK のコンテンツカードについて説明します。
前提条件
ろう付けコンテンツカードを使用する前に、Android SDK をアプリに統合する必要があります。ただし、追加のセットアップは必要ありません。
Googleフラグメント
Android では、コンテンツカードフィードは Braze Android UI プロジェクトで使用可能なフラグメントとして実装されます。このContentCardsFragment
クラスは、コンテンツカードの内容を自動的に更新して表示し、使用状況分析をログに記録します。ユーザーのContentCards
カードに表示できるカードは、Braze ダッシュボードで作成されます。
アクティビティにフラグメントを追加する方法については、Googleのフラグメントドキュメントを参照してください。
カードの種類とプロパティ
コンテンツカードデータモデルはAndroid SDK で利用でき、以下のユニークなコンテンツカードタイプを提供します。各タイプは基本モデルを共有しており、基本モデルから共通のプロパティを継承するだけでなく、独自の固有のプロパティも持つことができます。完全なリファレンスドキュメントについては、com.braze.models.cards
を参照してください。
ベースカードモデル
ベースカードモデルは、すべてのカードの基本的な動作を規定します。
プロパティ | 説明 |
---|---|
getId() |
Brazeで設定されたカードのID を返します。 |
getViewed() |
カードがユーザーによって既読か未読かを反映したブール値を返す。 |
getExtras() |
このカードのキーと値の追加のマップを返します。 |
getCreated() |
カードの作成時刻をBrazeからunixタイムスタンプで返す。 |
getIsPinned |
カードがピン留めされているかどうかを示すブール値を返す。 |
getOpenUriInWebView() |
このカードの Uris を開くべきかどうかを示すブール値を返す。 Braze WebView で開くべきかどうか |
getExpiredAt() |
カードの有効期限を取得する。 |
getIsRemoved() |
エンドユーザーがこのカードを退会したかどうかを示すブール値を返す。 |
getIsDismissible() |
カードがピン留めされているかどうかを示すブール値を返す。 |
画像のみ
画像のみのカードはクリック可能なフルサイズの画像です。
プロパティ | 説明 |
---|---|
getImageUrl() |
カードの画像のURLを返す。 |
getUrl() |
カードがクリックされた後に開かれるURLを返す。HTTP (s) URL でもプロトコル URL でもかまいません。 |
getDomain() |
プロパティ URL のリンクテキストを返します。 |
キャプション画像
キャプション付き画像カードはクリック可能なフルサイズの画像で、説明文が添えられています。
プロパティ | 説明 |
---|---|
getImageUrl() |
カードの画像のURLを返す。 |
getTitle() |
カードのタイトルテキストを返します。 |
getDescription() |
カードの本文を返します。 |
getUrl() |
カードがクリックされた後に開かれるURLを返す。HTTP (s) URL でもプロトコル URL でもかまいません。 |
getDomain() |
プロパティ URL のリンクテキストを返す。 |
クラシック
画像が含まれていないクラシック カードは、テキストアナウンス カードになります。画像が含まれている場合は、ショートニュースカードを受け取ります。
プロパティ | 説明 |
---|---|
getTitle() |
カードのタイトルテキストを返します。 |
getDescription() |
カードの本文を返します。 |
getUrl() |
カードがクリックされた後に開かれるURLを返す。HTTP (s) URL でもプロトコル URL でもかまいません。 |
getDomain() |
プロパティ URL のリンクテキストを返す。 |
getImageUrl() |
カードの画像の URL を返します。クラシックショートニュースカードにのみ適用されます。 |
カードメソッド
すべてのCard
データモデルオブジェクトは、ユーザーイベントを Braze サーバーに記録するための次の分析方法を提供します。
方法 | 説明 |
---|---|
logImpression() |
特定のカードのインプレッションを手動でBrazeに記録する。 |
logClick() |
特定のカードのBrazeへのクリックを手動で記録する。 |
setIsDismissed() |
特定のカードの消去を手動で Braze に記録します。カードがすでに却下済みとしてマークされている場合、そのカードを再度却下済みとしてマークすることはできません。 |
Prerequisites
Before you can use Content Cards, you’ll need to integrate the Braze Swift SDK into your app. However, no additional setup is required.
View controller contexts
The default Content Cards UI can be integrated from the BrazeUI
library of the Braze SDK. Create the Content Cards view controller using the braze
instance. If you wish to intercept and react to the Content Card UI lifecycle, implement BrazeContentCardUIViewControllerDelegate
as the delegate for your BrazeContentCardUI.ViewController
.
For more information about iOS view controller options, refer to the Apple developer documentation.
The BrazeUI
library of the Swift SDK provides two default view controller contexts: navigation or modal. This means you can integrate Content Cards in these contexts by adding a few lines of code to your app or site. Both views offer customization and styling options as described in the customization guide. You can also create a custom Content Card view controller instead of using the standard Braze one for even more customization options—refer to the Content Cards UI tutorial for an example.
To handle control variant Content Cards in your custom UI, pass in your Braze.ContentCard.Control
object, then call the logImpression
method as you would with any other Content Card type. The object will implicitly log a control impression to inform our analytics of when a user would have seen the control card.
Navigation
A navigation controller is a view controller that manages one or more child view controllers in a navigation interface. Here is an example of pushing a BrazeContentCardUI.ViewController
instance into a navigation controller:
1
2
3
4
5
6
7
func pushViewController() {
guard let braze = AppDelegate.braze else { return }
let contentCardsController = BrazeContentCardUI.ViewController(braze: braze)
// Implement and set `BrazeContentCardUIViewControllerDelegate` if you wish to intercept click actions.
contentCardsController.delegate = self
self.navigationController?.pushViewController(contentCardsController, animated: true)
}
1
2
3
4
5
6
- (void)pushViewController {
BRZContentCardUIViewController *contentCardsController = [[BRZContentCardUIViewController alloc] initWithBraze:self.braze];
// Implement and set `BrazeContentCardUIViewControllerDelegate` if you wish to intercept click actions.
[contentCardsController setDelegate:self];
[self.navigationController pushViewController:contentCardsController animated:YES];
}
Modal
Use modal presentations to create temporary interruptions in your app’s workflow, such as prompting the user for important information. This model view has a navigation bar on top and a Done button on the side of the bar. Here is an example of pushing a BrazeContentCard.ViewController
instance into a modal controller:
1
2
3
4
5
6
7
func presentModalViewController() {
guard let braze = AppDelegate.braze else { return }
let contentCardsModal = BrazeContentCardUI.ModalViewController(braze: braze)
// Implement and set `BrazeContentCardUIViewControllerDelegate` if you wish to intercept click actions.
contentCardsModal.viewController.delegate = self
self.navigationController?.present(contentCardsModal, animated: true, completion: nil)
}
1
2
3
4
5
6
- (void)presentModalViewController {
BRZContentCardUIModalViewController *contentCardsModal = [[BRZContentCardUIModalViewController alloc] initWithBraze:AppDelegate.braze];
// Implement and set `BrazeContentCardUIViewControllerDelegate` if you wish to intercept click actions.
[contentCardsModal.viewController setDelegate:self];
[self.navigationController presentViewController:contentCardsModal animated:YES completion:nil];
}
For example usage of BrazeUI
view controllers, check out the corresponding Content Cards UI samples in our Examples app.
Base card model
The Content Cards data model is available in the BrazeKit
module of the Braze Swift SDK. This module contains the following Content Card types, which are an implementation of the Braze.ContentCard
type. For a full list of Content Card properties and their usage, see ContentCard
class.
- Image only
- Captioned image
- Classic
- Classic image
- Control
To access the Content Cards data model, call contentCards.cards
on your braze
instance. See Logging analytics for more information on subscribing to card data.
Keep in mind, BrazeKit
offers an alternative ContentCardRaw
class for Objective-C compatibility.
Card methods
Each card is initialized with a Context
object, which contains various methods for managing your card’s state. Call these methods when you want to modify the corresponding state property on a particular card object.
Method | Description |
---|---|
card.context?.logImpression() |
Log the content card impression event. |
card.context?.logClick() |
Log the content card click event. |
card.context?.processClickAction() |
Process a given ClickAction input. |
card.context?.logDismissed() |
Log the content card dismissed event. |
card.context?.logError() |
Log an error related to the content card. |
card.context?.loadImage() |
Load a given content card image from a URL. This method can be nil when the content card does not have an image. |
For more details, refer to the Context
class documentation
このガイドでは、Braze Web SDK 4.0.0+ のコードサンプルを使用します。最新の Web SDK バージョンにアップグレードするには、SDK アップグレードガイドを参照してください。
Prerequisites
Before you can use Content Cards, you’ll need to integrate the Braze Web SDK into your app. However, no additional setup is required. To build your own UI instead, see Content Card Customization Guide.
Standard feed UI
To use the included Content Cards UI, you’ll need to specify where to show the feed on your website.
In this example, we have a <div id="feed"></div>
in which we want to place the Content Cards feed. We’ll use three buttons to hide, show, or toggle (hide or show based on its current state) the feed.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<button id="toggle" type="button">Toggle Cards Feed</button>
<button id="hide" type="button">Hide Cards Feed</button>
<button id="show" type="button">Show Cards Feed</button>
<nav>
<h1>Your Personalized Feed</h1>
<div id="feed"></div>
</nav>
<script>
const toggle = document.getElementById("toggle");
const hide = document.getElementById("hide");
const show = document.getElementById("show");
const feed = document.getElementById("feed");
toggle.onclick = function(){
braze.toggleContentCards(feed);
}
hide.onclick = function(){
braze.hideContentCards();
}
show.onclick = function(){
braze.showContentCards(feed);
}
</script>
When using the toggleContentCards(parentNode, filterFunction)
and showContentCards(parentNode, filterFunction)
methods, if no arguments are provided, all Content Cards will be shown in a fixed-position sidebar on the right-hand side of the page. Otherwise, the feed will be placed in the specified parentNode
option.
Parameters | Description |
---|---|
parentNode |
The HTML node to render the Content Cards into. If the parent node already has a Braze Content Cards view as a direct descendant, the existing Content Cards will be replaced. For example, you should pass in document.querySelector(".my-container") . |
filterFunction |
A filter or sort function for cards displayed in this view. Invoked with the array of Card objects, sorted by {pinned, date} . Expected to return an array of sorted Card objects to render for this user. If omitted, all cards will be displayed. |
See the SDK reference docs for more information on Content Card toggling.
Card types and properties
The Content Cards data model is available in the Web SDK and offers the following Content Card types: ImageOnly, CaptionedImage, and ClassicCard. Each type inherits common properties from a base model Card and has the following additional properties.
To log Content Card data, see Logging analytics.
Base card model
All Content Cards have these shared properties:
Property | Description |
---|---|
expiresAt |
The UNIX timestamp of the card’s expiration time. |
extras |
(Optional) Key-value pair data formatted as a string object with a value string. |
id |
(Optional) The id of the card. This will be reported back to Braze with events for analytics purposes. |
pinned |
This property reflects if the card was set up as “pinned” in the dashboard. |
updated |
The UNIX timestamp of when this card was last modified. |
viewed |
This property reflects whether the user viewed the card or not. |
isControl |
This property is true when a card is a “control” group within an A/B test. |
Image only
ImageOnly cards are clickable full-sized images.
Property | Description |
---|---|
aspectRatio |
The aspect ratio of the card’s image and serves as a hint before image loading completes. Note that the property may not be supplied in certain circumstances. |
categories |
This property is purely for organization in your custom implementation; these categories can be set in the dashboard composer. |
clicked |
This property indicates whether this card has ever been clicked on this device. |
created |
The UNIX timestamp of the card’s creation time from Braze. |
dismissed |
This property indicates if this card has been dismissed. |
dismissible |
This property reflects if the user can dismiss the card, removing it from view. |
imageUrl |
The URL of the card’s image. |
linkText |
The display text for the URL. |
url |
The URL that will be opened after the card is clicked on. |
Captioned image
CaptionedImage cards are clickable, full-sized images with accompanying descriptive text.
Property | Description |
---|---|
aspectRatio |
The aspect ratio of the card’s image and serves as a hint before image loading completes. Note that the property may not be supplied in certain circumstances. |
categories |
This property is purely for organization in your custom implementation; these categories can be set in the dashboard composer. |
clicked |
This property indicates whether this card has ever been clicked on this device. |
created |
The UNIX timestamp of the card’s creation time from Braze. |
dismissed |
This property indicates if this card has been dismissed. |
dismissible |
This property reflects if the user can dismiss the card, removing it from view. |
imageUrl |
The URL of the card’s image. |
linkText |
The display text for the URL. |
title |
The title text for this card. |
url |
The URL that will be opened after the card is clicked on. |
Classic
The ClassicCard model can contain an image with no text or a text with image.
Property | Description |
---|---|
aspectRatio |
The aspect ratio of the card’s image and serves as a hint before image loading completes. Note that the property may not be supplied in certain circumstances. |
categories |
This property is purely for organization in your custom implementation; these categories can be set in the dashboard composer. |
clicked |
This property indicates whether this card has ever been clicked on this device. |
created |
The UNIX timestamp of the card’s creation time from Braze. |
description |
The body text for this card. |
dismissed |
This property indicates if this card has been dismissed. |
dismissible |
This property reflects if the user can dismiss the card, removing it from view. |
imageUrl |
The URL of the card’s image. |
linkText |
The display text for the URL. |
title |
The title text for this card. |
url |
The URL that will be opened after the card is clicked on. |
Control group
If you use the default Content Cards feed, impressions and clicks will be automatically tracked.
If you use a custom integration for Content Cards, you need need log impressions when a Control Card would have been seen. As part of this effort, make sure to handle Control cards when logging impressions in an A/B test. These cards are blank, and while they aren’t seen by users, you should still log impressions in order to compare how they perform against non-Control cards.
To determine if a Content Card is in the Control group for an A/B test, check the card.isControl
property (Web SDK v4.5.0+) or check if the card is a ControlCard
instance (card instanceof braze.ControlCard
).
Card methods
Method | Description |
---|---|
logContentCardImpressions |
Logs an impression event for the given list of cards. This is required when using a customized UI and not the Braze UI. |
logContentCardClick |
Logs an click event for a given card. This is required when using a customized UI and not the Braze UI. |
showContentCards |
Display the user’s Content Cards. |
hideContentCards |
Hide any Braze Content Cards currently showing. |
toggleContentCards |
Display the user’s Content Cards. |
getCachedContentCards |
Get all currently available cards from the last Content Cards refresh. |
subscribeToContentCardsUpdates |
Subscribe to Content Cards updates. The subscriber callback will be called whenever Content Cards are updated. |
dismissCard |
Dismiss the card programmatically (available in v2.4.1). |
For more details, refer to the SDK reference documentation
Using Google Tag Manager
Google Tag Manager works by injecting the Braze CDN (a version of our Web SDK) directly into your website code, which means that all SDK methods are available just as if you had integrated the SDK without Google Tag Manager, except when implementing Content Cards.
Setting up Content Cards
For a standard integration of the Content Card feed, you can use a Custom HTML tag in Google Tag Manager. Add the following to your Custom HTML tag, which will activate the standard Content Card feed:
1
2
3
<script>
window.braze.showContentCards();
</script>
For more freedom over customizing the appearance of Content Cards and their feed, you can directly integrate Content Cards into your native website. There are two approaches you can take with this: using the standard feed UI or creating a custom feed UI.
Standard feed
When implementing the standard feed UI, Braze methods must have window.
added to the start of the method. For example, braze.showContentCards
should instead be window.braze.showContentCards
.
Custom feed UI
For custom feed styling, the steps are the same as if you had integrated the SDK without GTM. For example, if you want to customize the width of the Content Card feed, you can paste the following into your CSS file:
1
2
3
body .ab-feed {
width: 800px;
}
Upgrading templates
To upgrade to the latest version of the Braze Web SDK, take the following three steps in your Google Tag Manager dashboard:
- Update tag template
Go to the Templates page within your workspace. Here you should see an icon indicating an update is available.
Click that icon and after reviewing the change, click to Accept Update. - Update version number
Once your tag template has been updated, edit the Braze Initialization Tag, and update the SDK version to the most recentmajor.minor
version. For example, if the latest version is4.1.2
, enter4.1
. You can view a list of SDK versions in our changelog. - QA and publish
Verify the new SDK version is working using Google Tag Manager’s debugging tool prior to publishing an update to your tag container.
Troubleshooting
Enable tag debugging
Each Braze tag template has an optional GTM Tag Debugging checkbox which can be used to log debug messages to your web page’s JavaScript console.
Enter debug mode
Another way to help debug your Google Tag Manager integration is using Google’s Preview mode feature.
This will help identify what values are being sent from your web page’s data layer to each triggered Braze tag and will also explain which tags were or were not triggered.
Enable verbose logging
To allow Braze technical support to access logs while testing, you can enable verbose logging on your Google Tag Manager integration. These logs will appear in the Console tab of your browser’s developer tools.
In your Google Tag Manager integration, navigate to your Braze Initialization Tag and select Enable Web SDK Logging.
guide/prerequisites/cordova.md developer_ %}
カードフィード
Braze SDK にはデフォルトのカードフィードが含まれています。デフォルトのカードフィードを表示するには、launchContentCards()
メソッドを使用します。このメソッドは、ユーザーのコンテンツカードの分析トラッキング、却下、レンダリングをすべて行います。
コンテンツカード
以下の追加メソッドを使用して、アプリ内にカスタムコンテンツカードフィードを構築できます。
方法 | 説明 | |
---|---|---|
requestContentCardsRefresh() |
Braze SDKサーバーから最新のコンテンツカードを要求するためのバックグラウンドリクエストを送信する。 | |
getContentCardsFromServer(successCallback, errorCallback) |
Braze SDKからコンテンツカードを取得する。これにより、サーバーから最新のコンテンツカードが要求され、完了時にカードのリストが返されます。 | |
getContentCardsFromCache(successCallback, errorCallback) |
Braze SDKからコンテンツカードを取得する。これは、前回の更新時に更新されたローカルキャッシュから最新のカードリストを返す。 | |
logContentCardClicked(cardId) |
指定されたコンテンツカードIDのクリックを記録する。 | |
logContentCardImpression(cardId) |
与えられたコンテンツカードIDのインプレッションを記録する。 | |
logContentCardDismissed(cardId) |
指定されたコンテンツカード ID が閉じられたことを記録します。 |
フルッターコンテンツカードについて
Braze SDK には、コンテンツカードを使い始めるためのデフォルトのカードフィードが含まれています。カードフィードを表示するには、braze.launchContentCards()
メソッドを使用できます。Braze SDK に含まれるデフォルトのカードフィードは、ユーザーのコンテンツカードの分析トラッキング、却下、レンダリングをすべて処理します。
guide/prerequisites/flutter.md developer_ %}
カードメソッド
これらの追加メソッドを使用して、プラグインパブリックインターフェイス で使用可能な以下のメソッドを使用して、アプリ内でカスタムコンテンツカードフィードを構築できます。
方法 | 説明 |
---|---|
braze.requestContentCardsRefresh() |
Braze SDKサーバーから最新のコンテンツカードを要求する。 |
braze.logContentCardClicked(contentCard) |
与えられたContent Cardオブジェクトのクリックを記録する。 |
braze.logContentCardImpression(contentCard) |
与えられたContent Cardオブジェクトのインプレッションを記録する。 |
braze.logContentCardDismissed(contentCard) |
指定されたContent Cardオブジェクトの却下を記録する。 |
コンテンツカードデータの受信
Flutter アプリでコンテンツカードデータを受信するために、BrazePlugin
は Dart ストリームを使用したコンテンツカードデータの送信をサポートしています。
BrazeContentCard
オブジェクトは、description
、title
、image
、url
、extras
などを含む、ネイティブモデルオブジェクトで使用可能なフィールドのサブセットをサポートします。
ステップ 1:Dart レイヤーでコンテンツカードデータをリッスンする
Dart レイヤーでコンテンツカードデータを受信するには、以下のコードを使用して StreamSubscription
を作成し、braze.subscribeToContentCards()
を呼び出します。不要になったストリームサブスクリプションを忘れずに cancel()
してください。
1
2
3
4
5
6
7
8
9
// Create stream subscription
StreamSubscription contentCardsStreamSubscription;
contentCardsStreamSubscription = braze.subscribeToContentCards((List<BrazeContentCard> contentCards) {
// Handle Content Cards
}
// Cancel stream subscription
contentCardsStreamSubscription.cancel();
例としては main.dartを参照のこと。
ステップ2:ネイティブレイヤーからコンテンツカードデータを転送する
ステップ 1 の Dart レイヤーでデータを受信するには、次のコードを追加して、ネイティブレイヤーからコンテンツカードデータを転送します。
コンテンツカードデータは Android レイヤーから自動的に転送されます。
-
subscribeToUpdates のドキュメントの説明に従って、コンテンツカードの最新情報を購読登録するように
contentCards.subscribeToUpdates
を実装します。 -
contentCards.subscribeToUpdates
コールバックの実装ではBrazePlugin.processContentCards(contentCards)
を呼び出す必要があります。
例としては AppDelegate.swiftを参照のこと。
コンテンツカードのコールバックを再生する
コールバックが利用可能になる前にトリガーされたコンテンツカードを保存し、設定後に再生するには、BrazePlugin
の初期化時に次のエントリを customConfigs
マップに追加します。
1
BrazePlugin braze = new BrazePlugin(customConfigs: {replayCallbacksConfigKey: true});
About React Native Content Cards
The Braze SDKs include a default card feed to get you started with Content Cards. To show the card feed, you can use the Braze.launchContentCards()
method. The default card feed included with the Braze SDK will handle all analytics tracking, dismissals, and rendering for a user’s Content Cards.
Prerequisites
Before you can use this feature, you’ll need to integrate the React Native Braze SDK.
Cards methods
To build your own UI, you can get a list of available cards, and listen for updates to cards:
1
2
3
4
5
6
7
8
9
10
11
// Set initial cards
const [cards, setCards] = useState([]);
// Listen for updates as a result of card refreshes, such as:
// a new session, a manual refresh with `requestContentCardsRefresh()`, or after the timeout period
Braze.addListener(Braze.Events.CONTENT_CARDS_UPDATED, async (update) => {
setCards(update.cards);
});
// Manually trigger a refresh of cards
Braze.requestContentCardsRefresh();
If you choose to build your own UI to display cards, you must call logContentCardImpression
in order to receive analytics for those cards. This includes control
cards, which must be tracked even though they are not displayed to the user.
You can use these additional methods to build a custom Content Cards Feed within your app:
Method | Description |
---|---|
launchContentCards() |
Launches the Content Cards UI element. |
requestContentCardsRefresh() |
Requests the latest Content Cards from the Braze SDK server. The resulting list of cards is passed to each of the previously registered content card event listeners. |
getContentCards() |
Retrieves Content Cards from the Braze SDK. This returns a promise that resolves with the latest list of cards from the server. |
getCachedContentCards() |
Returns the most recent Content Cards array from the cache. |
logContentCardClicked(cardId) |
Logs a click for the given Content Card ID. This method is used only for analytics. To execute the click action, call processContentCardClickAction(cardId) in addition. |
logContentCardImpression(cardId) |
Logs an impression for the given Content Card ID. |
logContentCardDismissed(cardId) |
Logs a dismissal for the given Content Card ID. |
processContentCardClickAction(cardId) |
Perform the action of a particular card. |
Card types and properties
The Content Cards data model is available in the React Native SDK and offers the following Content Cards card types: Image Only, Captioned Image, and Classic. There’s also a special Control card type, which is returned to users that are in the control group for a given card. Each type inherits common properties from a base model in addition to its own unique properties.
Base card model
The base card model provides foundational behavior for all cards.
Property | Description |
---|---|
id |
The card’s ID set by Braze. |
created |
The UNIX timestamp of the card’s creation time from Braze. |
expiresAt |
The UNIX timestamp of the card’s expiration time. When the value is less than 0, it means the card never expires. |
viewed |
Whether the card is read or unread by the user. This does not log analytics. |
clicked |
Whether the card has been clicked by the user. |
pinned |
Whether the card is pinned. |
dismissed |
Whether the user has dismissed this card. Marking a card as dismissed that has already been dismissed will be a no-op. |
dismissible |
Whether the card is dismissible by the user. |
url |
(Optional) The URL string associated with the card click action. |
openURLInWebView |
Whether URLs for this card should be opened in the Braze WebView or not. |
isControl |
Whether this card is a control card. Control cards should not be displayed to the user. |
extras |
The map of key-value extras for this card. |
For a full reference of the base card, see the Android and iOS documentation.
Image only
Image only cards are clickable, full-sized images.
Property | Description |
---|---|
type |
The Content Card type, IMAGE_ONLY . |
image |
The URL of the card’s image. |
imageAspectRatio |
The aspect ratio of the card’s image. It is meant to serve as a hint before image loading completes. Note that the property may not be supplied in certain circumstances. |
For a full reference of the image only card, see the Android and iOS documentation.
Captioned image
Captioned image cards are clickable, full-sized images with accompanying descriptive text.
Property | Description |
---|---|
type |
The Content Card type, CAPTIONED . |
image |
The URL of the card’s image. |
imageAspectRatio |
The aspect ratio of the card’s image. It is meant to serve as a hint before image loading completes. Note that the property may not be supplied in certain circumstances. |
title |
The title text for the card. |
cardDescription |
The description text for the card. |
domain |
(Optional) The link text for the property URL, for example, "braze.com/resources/" . It can be displayed on the card’s UI to indicate the action/direction of clicking on the card. |
For a full reference of the captioned image card, see the Android and iOS documentation.
Classic
Classic cards have a title, description, and an optional image on the left of the text.
Property | Description |
---|---|
type |
The Content Card type, CLASSIC . |
image |
(Optional) The URL of the card’s image. |
title |
The title text for the card. |
cardDescription |
The description text for the card. |
domain |
(Optional) The link text for the property URL, for example, "braze.com/resources/" . It can be displayed on the card’s UI to indicate the action/direction of clicking on the card. |
For a full reference of the classic (text announcement) Content Card, see the Android and iOS documentation. For the classic image (short news) card, see the Android and iOS documentation.
Control
Control cards include all of the base properties, with a few important differences. Most importantly:
- The
isControl
property is guaranteed to betrue
. - The
extras
property is guaranteed to be empty.
For a full reference of the control card, see the Android and iOS documentation.
前提条件
コンテンツカードを使用する前に、Braze Swift SDKをアプリに統合する必要がある。その後、tvOSアプリの設定ステップを完了させる必要がある。
コンテンツカードは Swift SDK を使用するヘッドレス UI でサポートされているため、独自のカスタムUI を実装する必要があります。これには tvOS のデフォルト UI やビューは含まれません。
tvOSアプリを設定する
ステップ1:新しいiOSアプリを作成する
Braze で、[設定] > [アプリの設定] を選択し、[アプリの追加] を選択します。tvOS アプリの名前を入力し、tvOS ではなく、iOS を選択し、アプリの追加を選択します。
tvOSチェックボックスを選択した場合、コンテンツカードをtvOS用にカスタマイズすることはできない。
ステップ2:アプリのAPIキーを取得する
アプリの設定で、新しいtvOSアプリを選択し、アプリのAPIキーをメモする。このキーを使って Xcode でアプリを設定します。
ステップ3: BrazeKitを統合する
アプリの API キーを使用して、Xcode で Braze Swift SDK を tvOS プロジェクトに統合します。Braze Swift SDK から BrazeKit を統合するだけでよいです。
ステップ 4:カスタムUIを作成する
BrazeはtvOS上のコンテンツカードのデフォルトUIを提供していないため、自分でカスタマイズする必要がある。完全なチュートリアルについては、ステップ・バイ・ステップのチュートリアルを参照のこと:コンテンツカードをtvOS用にカスタマイズする。サンプルプロジェクトについては、Braze Swift SDKのサンプルを参照してください。
guide/prerequisites/unity.md developer_ %}
コンテンツカードをネイティブに表示する
次の呼び出しを使用して、コンテンツカードのデフォルトユーザーインターフェイスを表示できます。
1
Appboy.AppboyBinding.DisplayContentCards();
Unityでコンテンツカードデータを受信する
Unity ゲームオブジェクトを登録して、コンテンツカードの受信について通知を受けることができます。Brazeコンフィギュレーションエディタから設定のゲームオブジェクトリスナを使用することをお勧めします。
ゲームオブジェクトのリスナーを実行時に設定する必要がある場合は、AppboyBinding.ConfigureListener()
を使用し、BrazeUnityMessageType.CONTENT_CARDS_UPDATED
を指定します。
さらに、AppboyBinding.RequestContentCardsRefresh()
を呼び出して、iOS 上のゲームオブジェクトリスナーでデータの受信を開始する必要があります。
コンテンツカードの解析
Content Cards ゲームオブジェクトコールバックで受信した受信string
メッセージは、事前に提供されているContentCard
モデルオブジェクトに構文解析すると便利です。
コンテンツカードの解析にはJSON解析が必要で、詳細は以下の例を参照のこと:
コンテンツカードのコールバックの例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
void ExampleCallback(string message) {
try {
JSONClass json = (JSONClass)JSON.Parse(message);
// Content Card data is contained in the `mContentCards` field of the top level object.
if (json["mContentCards"] != null) {
JSONArray jsonArray = (JSONArray)JSON.Parse(json["mContentCards"].ToString());
Debug.Log(String.Format("Parsed content cards array with {0} cards", jsonArray.Count));
// Iterate over the card array to parse individual cards.
for (int i = 0; i < jsonArray.Count; i++) {
JSONClass cardJson = jsonArray[i].AsObject;
try {
ContentCard card = new ContentCard(cardJson);
Debug.Log(String.Format("Created card object for card: {0}", card));
// Example of logging Content Card analytics on the ContentCard object
card.LogImpression();
card.LogClick();
} catch {
Debug.Log(String.Format("Unable to create and log analytics for card {0}", cardJson));
}
}
}
} catch {
throw new ArgumentException("Could not parse content card JSON message.");
}
}
コンテンツカードの更新
Braze からコンテンツカードを更新するには、次のいずれかのメソッドを呼び出します。
1
2
3
4
// results in a network request to Braze
AppboyBinding.RequestContentCardsRefresh()
AppboyBinding.RequestContentCardsRefreshFromCache()
分析
Braze によって直接表示されないコンテンツカードについては、クリックとインプレッションを手動でログに記録する必要があります。
Content カード でLogClick()
およびLogImpression()
を使用して、特定のカードs のクリックとインプレッションを記録します。
Xamarin Contentカードについて
Braze Xamarin SDK には、コンテンツカードの使用を開始するためのデフォルトのカードフィードが含まれています。Braze SDKに含まれるデフォルトのカードフィードは、ユーザーのコンテンツカードのすべてのアナリティクスのトラッキング、却下、レンダリングを処理する。
guide/prerequisites/xamarin.md developer_ %}
カードの種類とプロパティ
Braze Xamarin SDK には、基本モデルを共有する3 つの独自のコンテンツカードタイプがあります。バナー、キャプションイメージ、およびクラシック。各タイプはベースモデルから共通のプロパティを継承し、次の追加プロパティを持ちます。
ベースカードモデル
プロパティ | 説明 |
---|---|
idString |
Braze によって設定されたカードの ID。 |
created |
Brazeからのカード作成時間のUNIXタイムスタンプ。 |
expiresAt |
カードの有効期限を示すUNIXタイムスタンプ。値が0より小さい場合は、カードの有効期限がないことを意味する。 |
viewed |
カードがユーザーによって読まれているか読まれていないか。これはアナリティクスのログを記録しない。 |
clicked |
カードがユーザーによってクリックされたかどうか。 |
pinned |
カードが固定されているかどうか。 |
dismissed |
ユーザーがこのカードを退会したかどうか。すでに閉じられたカードに閉じられたマークを付けることは、ノーオペになります。 |
dismissible |
ユーザーがカードを閉じられるかどうか。 |
urlString |
(オプション) カードクリックアクションに関連付けられたURL 文字列。 |
openUrlInWebView |
このカードのURL をBraze WebView で開くかどうか。 |
isControlCard |
このカードがコントロールカードかどうか。コントロールカードをユーザーに表示しないでください。 |
extras |
このカードのキー・バリュー・エキストラのマップ。 |
isTest |
このカードがテストカードかどうか。 |
ベースカードの完全なリファレンスについては、Android および iOS のドキュメントを参照してください。
バナー
バナーカードはクリック可能なフルサイズの画像である。
プロパティ | 説明 |
---|---|
image |
カードの画像のURL。 |
imageAspectRatio |
カード画像のアスペクト比。これは、画像の読み込みが完了する前にヒントとして利用するためです。特定の状況ではプロパティが提供されない場合があることに注意してください。 |
バナーカードの完全なリファレンスについては、Android および iOS のドキュメント (現在は画像のみに名称変更) を参照してください。
キャプション付き画像
キャプション付き画像カードはクリック可能なフルサイズの画像で、説明文が添えられています。
プロパティ | 説明 |
---|---|
image |
カードの画像のURL。 |
imageAspectRatio |
カード画像のアスペクト比。これは、画像の読み込みが完了する前にヒントとして利用するためです。特定の状況ではプロパティが提供されない場合があることに注意してください。 |
title |
カードのタイトルテキスト。 |
cardDescription |
カードの説明テキスト。 |
domain |
(オプ シ ョ ナル) プ ロパテ ィ URL の リ ン ク テキス ト 、 た と えば"braze.com/resources/" 。カードの UI に表示され、カードをクリックした時の動作/方向を示すことができます。 |
キャプション付き画像カードの完全なリファレンスについては、Android および iOS のドキュメントを参照してください。
クラシック
クラシックカードには、タイトル、説明、およびオプションの画像がテキストの左側に表示されます。
プロパティ | 説明 |
---|---|
image |
(オプション)カードの画像のURL。 |
title |
カードのタイトルテキスト。 |
cardDescription |
カードの説明テキスト。 |
domain |
(オプ シ ョ ナル) プ ロパテ ィ URL の リ ン ク テキス ト 、 た と えば"braze.com/resources/" 。カードの UI に表示され、カードをクリックした時の動作/方向を示すことができます。 |
クラシック (テキストアナウンス) コンテンツカードの完全なリファレンスについては、Android および iOS のドキュメントを参照してください。クラシック画像 (ショートニュース) カードの完全なリファレンスについては、Android および iOS のドキュメントを参照してください。
カードメソッド
以下の追加メソッドを使用して、アプリ内にカスタムコンテンツカードフィードを構築できます。
方法 | 説明 |
---|---|
requestContentCardsRefresh() |
Braze SDKサーバーから最新のコンテンツカードを要求する。 |
getContentCards() |
Braze SDKからコンテンツカードを取得する。これでサーバーから最新のカードリストが返される。 |
logContentCardClicked(cardId) |
指定されたコンテンツカードIDのクリックを記録する。この方法は、分析でのみ使用されます。 |
logContentCardImpression(cardId) |
与えられたコンテンツカードIDのインプレッションを記録する。 |
logContentCardDismissed(cardId) |
指定されたコンテンツカード ID が閉じられたことを記録します。 |