This section describes how to validate your integration by forcing inline campaigns to appear in specific locations, ensuring that the component's expansion and collapse behavior does not interfere with your existing UI layouts.
he Contextual Commerce SDK provides a method
Granify.overrideGranifyInlineView which forces the SDK to use specific locations for display during testing.
Step 1: Translate labels to JSON
-
Use snake_case keys. Convert Kotlin parameters (
productId) to snake_case JSON keys (product_id). -
Target specific products. Include exact
product_idandskuvalues to test specific items. -
Use wildcards for general testing. Set
product_idandskutonullto match any label by name, regardless of the product. -
Verify dependencies. Ensure
product_idis included whenever askuis provided.
Note: You can also use a partial wildcard by setting
sku to null while providing a specific product_id. This targets any label on that product, regardless of the specific SKU.
Conversion example:
| Kotlin label |
|
||
|
JSON equivalent (specific): |
|
||
|
JSON equivalent (wildcard): |
|
Step 2: Format the JSON array
The SDK expects the input to be an array of labels. To do this follow these instructions:
-
Enclose objects in brackets. Wrap the input in
[]to form a JSON array, even when testing a single location. - Order labels by priority. Place the highest priority label first. The SDK selects the first match found on the page.
- Format as a String. Escape quotes or use Kotlin raw strings to ensure valid JSON formatting.
Code example:
Code |
|
Step 3: Call the override method
Follow these steps to pass your JSON string to the override method and lock the SDK into testing mode:
-
Pass the JSON string to the SDK. Call
Granify.overrideGranifyInlineView(label: String?)with your formatted string. - Add a text box to your debug menu to pass input to this method. This enables testing different locations without recompiling.
Method call:
Code |
Granify.overrideGranifyInlineView(overrideLabelString) |
Step 4: Verify the UI
After the override is set, verify the behavior in the app by following these steps:
- Force a campaign match. Trigger a specific inline campaign using the ID provided by Contextual Commerce during installation.
- Navigate to the target page. Open the page containing the added composable.
- Observe the behavior. Verify the campaign appears in the first matching location from the JSON list and that the UI handles the insertion gracefully.
Inline campaigns are not affected by restricted states. They will not be hidden while in a restricted state.
Step 5: Reset testing mode
When testing is complete, you must disable the override to return to standard SDK behavior by following this instruction:
Call the override method with null. Passing null resets the SDK to its default behavior, where Contextual Commerce automatically selects the best location.
Reset call:
Code |
Granify.overrideGranifyInlineView(null) |