HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket


Note

Sample code in this article is taken from Quicksilver templates. The _Quicksilver_ Commerce sample site and installation instructions are available for [download from GitHub](🔗).

## Preparation

See [API overview](🔗)  for the initialization steps, then continue with the steps below.

### 1. Define the recommended sections

To the _Views/Shared/\_Layout.cshtml_ view, add following sections:

  • UpperRecommendations

  • LeftMarginRecommendations

  • RightMarginRecommendations

  • BottomRecommendations

to the <div> tags defined in the preparation step.



### 2. Define the recommendations view

To render the recommendations layout based on the recommended data, create a partial view. In the Quicksilver sample site, this is _Views/Recommendations/\_Recommendations.cshtml_.



## Use the CommerceTrackingAttribute

This section explains how to create, send, then consume recommendations on a page using the CommerceTrackingAttribute. In this example, the integration is applied to a StartPage.

### 1. Create and send a tracking request

For the controller _Features/Start/Controllers/StartController_,add the CommerceTracking attribute to the Index  action.



### 2. Consume recommendations

For the controller _Features/Start/Controllers/StartController_, use GetHomeRecommendations from RecommendationsExtensions to get a collection of recommendation objects for the home page.



To the view _Views/Start/Index.cshtml_, add the following to render the recommended data in the _RightMarginRecommendations_ section of the page.



## Track without using the CommerceTracking Attribute

This section explains how to create, send, then consume recommendations on a page or an action without using the CommerceTrackingAttribute. This integration is applied to a Product package page.

### 1. Create and send a tracking request

For the controller _Features/Product/Controllers/PackageController_, add following code to the Index action.



Then add the **\_recommendationService.TrackingProduct()** method.



### 2. Consume recommendations

To the controller _Features/Product/Controllers/PackageController_, add following code to the Index action.



To the view _Views/Package/Index.cshtml_, add the following.