Overview
The Citation & Product Format displays recommendations as a separate UI element below your LLM responses. This is the simplest way to integrate AdMesh - just add a component and it handles everything automatically. What you get:- ✅ Automatic rendering of recommendations
- ✅ Automatic tracking (impressions and clicks)
- ✅ Transparency labels (
[Ad]added automatically) - ✅ Session-aware tracking
- ✅ Multiple format options (citation or product cards)
Component: AdMeshRecommendations
TheAdMeshRecommendations component is specifically designed for Citation and Product formats. It displays recommendations as a separate UI element (not embedded in your content).
Use this component if:
- ✅ You want a separate recommendations panel
- ✅ You want Citation format (inline citations with links)
- ✅ You want Product format (product cards)
- ✅ You want automatic rendering and tracking
- ❌ You want to embed links directly in LLM responses (use Weave Ad Format instead)
Quick Start - Provider Pattern (Recommended)
The Provider Pattern is the simplest approach - just 3 lines of code!1
Install the SDK
2
Wrap with AdMeshProvider
3
Add AdMeshRecommendations Component
4
Done!
The SDK automatically:
- Initializes the SDK
- Fetches recommendations based on the query
- Shows recommendations in the specified format
- Tracks exposures and clicks
- Handles all API communication
Format Types
Citation Format
Displays a summary with embedded product links. Ideal for conversational interfaces.Product Format
Displays product recommendation cards with key details. Suitable for SaaS or software listings.Session Management
TheAdMeshProvider manages sessions automatically using the sessionId prop you provide. Each message should have a unique messageId and the user’s original query.
Best practice: Always pass your ownsessionIdandmessageIdwhen available. Store the user’s original query with each assistant message to enable contextual recommendations.
Customization
Theme Customization
Event Handlers
onRecommendationsShown: Called when recommendations are successfully displayedonError: Called if there’s an error fetching or displaying recommendations
Automatic Tracking
The SDK automatically manages:- Exposure tracking - when recommendations are rendered
- Click tracking - when users engage with recommendations
- Conversion tracking - if configured
- Transparency labels -
[Ad]automatically added
Complete Integration Example
Optional: Backend Integration
While theadmesh-ui-sdk handles all recommendation fetching from the frontend, you can optionally pre-fetch recommendations on your backend for caching or custom logic.
When to Use Backend Integration
- ✅ You want to cache recommendations server-side
- ✅ You need to filter or customize recommendations before displaying
- ✅ You want to reduce frontend API calls
- ✅ You’re implementing server-side rendering (SSR)
Backend SDK Installation
Fetching Recommendations on Backend
Note: Backend integration is optional. The admesh-ui-sdk can fetch recommendations directly from the frontend without any backend code.
Best Practices
✅ DO:- Always provide the
queryparameter (required for contextual recommendations) - Pass your own
sessionIdandmessageIdfor accurate tracking - Store the user’s original query with each assistant message
- Use the SDK for rendering and tracking
- Customize themes to match your brand
- Use separate sessions for each conversation
- Omit the
queryparameter (recommendations won’t be contextual) - Manually trigger tracking events
- Modify or remove transparency labels
- Render recommendations outside the container
- Reuse session IDs across conversations
Troubleshooting
Recommendations Not Showing
Recommendations Not Showing
Check:
queryprop is provided and not empty (required)messageIdprop is provided- API key is valid and set in environment variables
sessionIdprop is provided toAdMeshProvider- Component is wrapped inside
AdMeshProvider
Query Parameter Missing
Query Parameter Missing
Problem: The Then pass it to the component:
query parameter is required for contextual recommendations.Solution: Store the user’s original query with each message:API Key Issues
API Key Issues
Check:
- API key is valid and active
- Environment variable is set correctly
- No extra spaces or quotes in the key
Tracking Not Working
Tracking Not Working
Tracking is managed automatically by the SDK. Do not modify tracking logic or URLs manually. The SDK handles all tracking internally.The SDK automatically tracks:
- Exposure events when recommendations are shown
- Click events when users interact with recommendations
- All tracking is handled internally - no manual setup needed
Messages Not Updating
Messages Not Updating
Ensure:
- Each message has a unique
messageId - Each message stores the original
query - Messages array is updated when new messages arrive
- Component is re-rendering with new messages