NOTE: Requires updates in release MS-0288, or a patch to be provided by Kademi support
The Reward Selector component adds a dropdown to a website page that lets participants choose a promotion or points bucket. Every reporting component on the page that uses an index query with the $selectedRewards filter then shows data for that choice only: totals, charts and tables all update together.
This article covers two things:
- Adding the Reward Selector to a page and choosing what it lists
- Filtering an index query with
$selectedRewardsso your reporting components follow the selection
- The KPromotions app must be enabled on the website. Without it the selector has nothing to list.
- Put the page behind a login. Reporting data is worked out for the logged-in user, so the components cannot show data to anonymous visitors.
Part 1: Add the Reward Selector to a page
Open the page in the content editor and click Add content where you want the selector to appear. In the component picker, search for reward selector (1), then drag the Reward Selector component (2) onto your page.
Choose what the selector lists
Hover over the component and click the settings (cog) icon on its toolbar (1). In the settings panel, choose an option under Show (2):
- Promotions only: the default. Lists your promotions.
- Points buckets only: lists your points buckets.
- Promotions and points buckets: lists both, promotions first.
Choose the option that matches the data your reporting components show. There is more on this in Part 2.
Save the page.
What participants see
The selector shows as a dropdown button (1). When nothing is selected, it reads [All promotions] (or [All points buckets], or [All promotions and points buckets], depending on the setting) and the reporting components show everything. Participants pick a promotion or points bucket from the list (2).
The page reloads and every reporting component on it shows data for the selected item only. The button shows the current selection.
The selection is remembered in the participant's browser, so it carries across every page that uses the same queries. Choosing Clear selection returns to showing everything.
Part 2: Filter an index query with $selectedRewards
The selector does nothing on its own. Reporting components follow it only when their index query is filtered with the $selectedRewards placeholder. When the page loads, Kademi replaces $selectedRewards with the names of what the participant selected. If nothing is selected, it is replaced with every promotion and points bucket, so the query shows all its data.
Pick an index that has a Reward Name
The filter works on the Reward Name field, so the query must use an index that records which promotion or points bucket each record belongs to:
- rewardEntries (promotion entries): Reward Name is the promotion. Use Promotions only on the selector.
- rewardpoints (points issued): Reward Name is the points bucket. Use Points buckets only on the selector.
If one page has reporting on both, use Promotions and points buckets. Selecting a promotion then shows nothing in the points components, and selecting a points bucket shows nothing in the promotion components.
Add the filter
- Go to Reporting > Index Queries and open your query, or create a new one on one of the indexes above.
- Click Edit filters.
- Add a rule and set the field to Reward Name (1), the operator to in (2), and the value to
$selectedRewards(3). Type the value exactly as shown, including the$. - Click Save.
The View all query parameters link, circled above, lists the other placeholders you can use in the same way, such as $startDate and $endDate.
Back on the query page, the filter summary shows the rule. In the admin console, where there is no selector, the query shows all its data.
Show the query on the page
On the same page as the Reward Selector, add reporting components, such as Single Value, Pie Chart or Query Table. In each component's settings, choose this index query and the aggregation to show. Every component that uses the query follows the selector.
Troubleshooting
- The selector lists nothing: check that the KPromotions app is enabled on the website, and that the Show setting matches what you have set up (for example, Points buckets only on an account with no points buckets lists nothing).
- A component shows 0 or "No records" after a selection: the selected promotion or points bucket has no data in that index. Check that the selector's Show setting matches the index the query uses.
- Components show an error: the page is being viewed without logging in. Restrict the page to logged-in users.
- Components do not change when a selection is made: the component's index query does not have the
$selectedRewardsfilter.