<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Adaptive Experiences in SharePoint 2013</title><link>http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/</link><description /><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title> Adaptive experiences in a Product Catalog in SharePoint 2013 using Facebook location data</title><link>http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/2012/11/16/adaptive-experiences-in-a-product-catalog-in-sharepoint-2013-using-facebook-location-data.aspx</link><pubDate>Fri, 16 Nov 2012 14:49:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10369248</guid><dc:creator>Anders Fagerhaug (PM)</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/rsscomments.aspx?WeblogPostID=10369248</wfw:commentRss><comments>http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/2012/11/16/adaptive-experiences-in-a-product-catalog-in-sharepoint-2013-using-facebook-location-data.aspx#comments</comments><description>&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;This is the second blog&lt;/strong&gt; &lt;strong&gt;post &lt;/strong&gt;on the topic of Adaptive Experience using User Segmentation. In this blog post I will go through how to use data from Facebook to differentiate the users on location, and use this to drive the user experience.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;Adaptive Experience is about tailoring the user experience in order to better match the interests of the end user. This can have a great effect on sales, since a better match between products and user needs increases the chance of a sale. &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Let&amp;rsquo;s take a look at the following scenario:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Pete Smith owns an online store selling electrical consumer goods. New Windows mobile 8 phones have arrived recently, and Pete wants to run a marketing campaign towards &lt;strong&gt;Norwegian users&lt;/strong&gt;. To do this he will have to segment his end users by country, also referred to as location. &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;In order to differentiate between end users, he divides them into different user segments and gives the different user segments a different user experience. While those end users located in Norway will get an Ad displaying one of the newest Windows mobile phones in stock, end users from other countries will not see this particular campaign. They may be offered other products (but that is not a part of this example). &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;By segmenting his users and giving different user experiences to different end users, Pete is able to tailor his market campaigns towards a specific set of end users. He could segment his users by numerous things; browser, gender, age, etc&amp;nbsp; as long as he has this data available.&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;This blog post&lt;/strong&gt; describes how to set up user segmentation based on location, and how we can change the user experience in a product catalog by the use of Query Rules. The &lt;strong&gt;only custom made parts&lt;/strong&gt; in this example are the web part placing the &lt;strong&gt;Login with Facebook&lt;/strong&gt; button on the category page, and the &lt;strong&gt;web part&lt;/strong&gt; which are fetching the end user location data from Facebook and matching it with custom properties in the user segments. I will give code examples on the most important parts of these web parts. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;strong&gt;&lt;span style="color: #000000; font-family: Calibri;"&gt;Content of this blog post:&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="color: #000000; font-family: Calibri;"&gt;This is how it&amp;rsquo;s working&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000; font-family: Calibri;"&gt;Prerequisites&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000; font-family: Calibri;"&gt;Create a term set defining the User Segments.&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000; font-family: Calibri;"&gt;Create a custom web part that fetches the location data from facebook&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000; font-family: Calibri;"&gt;Add the facebook login button to your category page&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000; font-family: Calibri;"&gt;Create an image to be used as the Ad&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000; font-family: Calibri;"&gt;Create a Query Rule that will activate on users from Norway&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000; font-family: Calibri;"&gt;Add a web part to the category page for displaying the Ad&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000; font-family: Calibri;"&gt;Verify the end result&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #000000; font-family: Calibri; font-size: x-small;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/8741.Image1.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/8741.Image1.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;While on the ContosoElectronics web site, the customer is logging into the web site using his Facebook credentials. By doing this he&amp;rsquo;s making his &lt;strong&gt;location-data&lt;/strong&gt; (stored in Facebook) available to the custom made targeted content search web part. The custom web part (web part 2) fetches the location data from Facebook, and matches it against&lt;strong&gt; Custom Properties&lt;/strong&gt; for &lt;strong&gt;User Segment Terms&lt;/strong&gt; in the term set. When matching, the GUID for the relevant &lt;strong&gt;User Segment name (Norway) &lt;/strong&gt;is added as a parameter to the &lt;strong&gt;search query&lt;/strong&gt; which is sent to the index to fetch items to be presented in web part 2. A&lt;strong&gt; Query Rule &lt;/strong&gt;monitors the search queries, and &lt;strong&gt;activates when the search parameter equals the GUID for the user segment Norway&lt;/strong&gt;. The Query Rule is configured to return a search result (the Ad), to the web part sending the query in the first place. The Ad is a part of the result set &lt;strong&gt;SpecialTermResults. &lt;/strong&gt;Another web part (web part 1) is added to the web site in order to display the Ad (Promotion). This web part does not send out search queries, but fetches results from web part 2. The result set &lt;strong&gt;SpecialTermResult&lt;/strong&gt; is fetched. This contains the Ad sent from the &lt;strong&gt;Query Rule&lt;/strong&gt;, and consists of a &lt;strong&gt;Title&lt;/strong&gt; and an &lt;strong&gt;URL&lt;/strong&gt; to the image to be promoted. Web part 2 can now display the Ad for the new Windows mobile phone.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Prerequisites&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;A Product catalog site collection has been created.&lt;/span&gt;&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;A list of products has been created&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Navigation term set is created&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Products list is shared with publishing site collection using XSP.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;A publishing site collection has been created.&lt;/span&gt;&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The web site is build up by a category page, and an item details page to display the items.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The site collection is available to anonymous users&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Skills to create custom web parts in Visual Studio and deploy them in SharePoint as a Solution&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Let&amp;rsquo;s see how all the different parts are configured to get this scenario working.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Create a term set defining the User Segments.&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;On your publishing site, in SharePoint, navigate to &lt;strong&gt;Site Settings=&amp;gt; Term store management =&amp;gt;&lt;/strong&gt; &lt;strong&gt;Taxonomy term store&lt;/strong&gt;. In the &lt;strong&gt;Taxonomy Term Store&lt;/strong&gt; navigation pane at the left, navigate to &lt;strong&gt;Managed Metadata Service =&amp;gt; Site collection&lt;/strong&gt; (the one mapped to the product catalog site collection). &lt;strong&gt;Create a new term set (User Segments).&lt;/strong&gt; Then create the term &lt;strong&gt;Location&lt;/strong&gt;, and the child terms &lt;strong&gt;Norway, UK and US.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/6366.Image2.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/300x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/6366.Image2.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;For each child term in the &lt;strong&gt;Browser Type&lt;/strong&gt; term set, click on &lt;strong&gt;Custom Properties&lt;/strong&gt; tab, and add unique properties for that user segment in the &lt;strong&gt;Shared Properties&lt;/strong&gt; section.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Shared Property Name:&lt;strong&gt; fbName&lt;/strong&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Value: Set the &lt;strong&gt;User Agent String &lt;/strong&gt;for that particular location. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;E.g:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;For user segment term &lt;strong&gt;Norway&lt;/strong&gt;,&lt;strong&gt; Value= Norway. &lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;For user segment&lt;strong&gt; &lt;/strong&gt;term &lt;strong&gt;UK, value=United Kingdom.&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;For user segment&lt;strong&gt; &lt;/strong&gt;term &lt;strong&gt;US, value=United States&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;These values have to match the location values fetched from Facebook.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/3678.Image3.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/3678.Image3.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Create a custom web part that fetches the location data from facebook&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;You will have to create your own custom solution in Visual Studio. This project is called SPCDemoWebParts. The custom web part you are creating has to be a part of this solution. In Visual Studio give the custom web part at title and in which category the web part will end up in.&lt;br /&gt;T&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;his custom web part will be a modified ContentBySearchWebPart. This is done by sub-classing the ContentBySearchWebPart and adding the methods described below.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;hellip;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;using&amp;nbsp;Microsoft.SharePoint;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;using&amp;nbsp;Microsoft.SharePoint.Taxonomy;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;using&amp;nbsp;Microsoft.Office.Server.Search.WebControls;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; using&amp;nbsp;Facebook;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;namespace&amp;nbsp;SPCDemoWebParts.TargetedContentSearch&lt;br /&gt;&lt;/em&gt;&lt;em&gt;{&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[ToolboxItemAttribute(false)]&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;partial&amp;nbsp;class&amp;nbsp;TargetedContentSearch&amp;nbsp;:&amp;nbsp;ContentBySearchWebPart&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;hellip;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;Note that you will also need to add some references to required assemblies for your project. To use the Facebook API from your project, you will need to download and install the Facebook SDK from &lt;/span&gt;&lt;a href="http://csharpsdk.org/"&gt;&lt;span style="color: #0000ff; font-family: Calibri; font-size: small;"&gt;http://csharpsdk.org/&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/4380.Image4.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/300x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/4380.Image4.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;In addition to show content by search, it will also fetch the &lt;strong&gt;location&lt;/strong&gt; given by Facebook. The web part will check each part for a matching &lt;strong&gt;custom property&lt;/strong&gt; in the term store.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre style="background: white;"&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;private&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;void&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;AddFacebookSegmentTerms(&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;List&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;string&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;gt;&amp;nbsp;userSegmentTerms,&amp;nbsp;TermStore&amp;nbsp;termStore)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;var&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;fbCookie&amp;nbsp;=&amp;nbsp;Page.Request.Cookies[&lt;/span&gt;&lt;span style="color: #a31515; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;"Facebook.AccessToken"&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;];&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;if&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;(fbCookie&amp;nbsp;==&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;null&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;return&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;string&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;access_token&amp;nbsp;=&amp;nbsp;(&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;string&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;)fbCookie.Value;&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background: white;"&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;var&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;fb&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;new&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;FacebookClient(access_token);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: green; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;//&amp;nbsp;Fix&amp;nbsp;for&amp;nbsp;SSL&amp;nbsp;issues&amp;nbsp;with&amp;nbsp;making&amp;nbsp;web&amp;nbsp;requests&amp;nbsp;to&amp;nbsp;Facebook&amp;nbsp;API&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Net.ServicePointManager.ServerCertificateValidationCallback&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;delegate&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;(&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;object&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;sender1,&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Security.Cryptography.X509Certificates.&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;X509Certificate&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;certificate,&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Security.Cryptography.X509Certificates.X509Chain&amp;nbsp;chain,&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Net.Security.SslPolicyErrors&amp;nbsp;sslPolicyErrors)&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;return&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;true&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;;&amp;nbsp;};&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre style="background: white;"&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: green; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;//&amp;nbsp;User&amp;nbsp;country&amp;nbsp;is&amp;nbsp;not&amp;nbsp;available&amp;nbsp;in&amp;nbsp;graph&amp;nbsp;api.&amp;nbsp;Use&amp;nbsp;fql&amp;nbsp;instead.&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;var&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;result&amp;nbsp;=&amp;nbsp;(JsonObject)fb.Get(&lt;/span&gt;&lt;span style="color: #a31515; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;"fql"&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;New&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;q&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color: #a31515; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;"SELECT&amp;nbsp;current_location&amp;nbsp;FROM&amp;nbsp;user&amp;nbsp;WHERE&amp;nbsp;uid=me()"&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;});&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;JsonArray&amp;nbsp;data&amp;nbsp;=&amp;nbsp;(JsonArray)result[&lt;/span&gt;&lt;span style="color: #a31515; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;"data"&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;];&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;JsonObject&amp;nbsp;entry&amp;nbsp;=&amp;nbsp;(JsonObject)data[0];&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;JsonObject&amp;nbsp;location&amp;nbsp;=&amp;nbsp;(JsonObject)entry[&lt;/span&gt;&lt;span style="color: #a31515; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;"current_location"&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;];&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;if&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;(location&amp;nbsp;==&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;null&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;return&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;;&amp;nbsp;&lt;/span&gt;&lt;span style="color: green; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;//&amp;nbsp;User&amp;nbsp;has&amp;nbsp;not&amp;nbsp;set&amp;nbsp;location&amp;nbsp;on&amp;nbsp;Facebook&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;string&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;country&amp;nbsp;=&amp;nbsp;(&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;string&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;)location[&lt;/span&gt;&lt;span style="color: #a31515; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;"country"&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;];&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background: white;"&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TermCollection&amp;nbsp;terms&amp;nbsp;=&amp;nbsp;termStore.GetTermsWithCustomProperty(&lt;/span&gt;&lt;span style="color: #a31515; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;"fbName"&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;,&amp;nbsp;country,&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;false&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;if&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;(terms.Count&amp;nbsp;&amp;gt;&amp;nbsp;0)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;var&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;term&amp;nbsp;=&amp;nbsp;terms[0].Id.ToString();&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;userSegmentTerms.Add(term);&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: green; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;//&amp;nbsp;TODO:&amp;nbsp;You&amp;nbsp;probably&amp;nbsp;want&amp;nbsp;to&amp;nbsp;cache&amp;nbsp;this&amp;nbsp;term&amp;nbsp;to&amp;nbsp;avoid&amp;nbsp;Facebook&amp;nbsp;roundtrip&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The GUID of any matching term for the location will then be added to the search query for fetching products. This is done by adding the list of GUIDs to the UserSegmentTerms property of the &lt;span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA;" lang="EN-US"&gt;DataProviderWebPart.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;&lt;em&gt;private&amp;nbsp;void&amp;nbsp;AddMycustomProperties(object&amp;nbsp;sender,&amp;nbsp;BeforeSerializeToClientEventArgs&amp;nbsp;e)&lt;/em&gt;&lt;br /&gt;&lt;em&gt;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DataProviderScriptWebPart&amp;nbsp;dataProvider&amp;nbsp;=&amp;nbsp;sender&amp;nbsp;as&amp;nbsp;DataProviderScriptWebPart;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;List&amp;lt;string&amp;gt;&amp;nbsp;userSegmentTerms&amp;nbsp;=&amp;nbsp;new&amp;nbsp;List&amp;lt;string&amp;gt;();&lt;/em&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AddUserAgentSegmentTerms(userSegmentTerms);&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dataProvider.Properties["UserSegmentTerms"]&amp;nbsp;=&amp;nbsp;userSegmentTerms.ToArray();&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&amp;nbsp; }&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;This code assumes that you have previously obtained a Facebook access token for the given user and stored it somewhere. This example has stored it in a cookie, but you can also store it in the ASP session object or with your user data. You can find more information about obtaining an access token in the &lt;/span&gt;&lt;a href="http://csharpsdk.org/docs/web/getting-started"&gt;&lt;span style="color: #0000ff; font-family: Calibri; font-size: small;"&gt;documentation&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt; for the &lt;/span&gt;&lt;a href="http://csharpsdk.org/"&gt;&lt;span style="color: #0000ff; font-family: Calibri; font-size: small;"&gt;Facebook C# SDK&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;. &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;All that now remains is to stitch the AddMycustomProperties into the OnLoad method of the web part, so it&amp;rsquo;s called before the page is rendered.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre style="background: white;"&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;protected&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;override&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;void&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;OnLoad(&lt;/span&gt;&lt;span style="color: #2b91af; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;EventArgs&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;e)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;if&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;(&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;this&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;.AppManager&amp;nbsp;!=&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;null&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;if&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;(&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;this&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;.AppManager.QueryGroups.ContainsKey(&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;this&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;.QueryGroupName)&amp;nbsp;&amp;amp;&amp;amp;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;this&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;.AppManager.QueryGroups[&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;this&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;.QueryGroupName].DataProvider&amp;nbsp;!=&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;null&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;this&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;.AppManager.QueryGroups[&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;this&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;.QueryGroupName].DataProvider.BeforeSerializeToClient&amp;nbsp;+=&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;new&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;BeforeSerializeToClientEventHandler(AddMycustomProperties);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: blue; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;base&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;.OnLoad(e);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9pt;" lang="EN-US"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The same method can easily be used for segmenting users in other ways based on browsing history or login information.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The custom web part created shall be packaged as a solution with a .wsp extension.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-size: small;"&gt;You will have to upload the solution into&amp;nbsp;the Public site Collection, and use it when setting up the category page, to display items in a category.&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3&gt;&lt;span style="font-size: small;"&gt;&lt;span style="color: #4f81bd;"&gt;&lt;span style="font-family: Cambria;"&gt;Upload the custom web part as a solution&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Assuming the .wsp file is placed in C:\Temp\MyCustomWebPart.wsp&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Start &amp;laquo;SharePoint&amp;raquo; 2013 Management Shell as Administrator&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Run: &lt;strong&gt;&lt;em&gt;Add-SPSolution -LiteralPath C:\temp\MyCustomWebPart.wsp&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;em&gt;Run:&lt;strong&gt; Install-SPSolution -identity MyCustomWebPart.wsp -GACDeployment &amp;ndash;AllWebApplications&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;In the publishing site collection, navigate to &lt;strong&gt;Site settings=&amp;gt; Site collection Administration =&amp;gt; Site collection features:&amp;nbsp; &lt;/strong&gt;Deactivate and activate site collection feature "&lt;strong&gt;Adaptive Experiences WebParts&lt;/strong&gt;"&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: #4f81bd;"&gt;&lt;span style="font-family: Cambria;"&gt;Obtain access to Facebook user location data&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;There are many ways of communicating with Facebook to retrieve user information. I will not go into details on that here, but will leave it to you to choose your own model. In order to be able to retrieve the end user location data from Facebook, the end user could log into the Contoso web page, using Facebook credentials. By doing this the end user agrees on letting the Contoso page fetch the end user&amp;rsquo;s location data from Facebook. &lt;strong&gt;The purpose of this action is to obtain an access_token to the end users&amp;rsquo; Facebook profile, so that user location data can be retrieved.&lt;/strong&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Documentation on the subject can be found here:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://csharpsdk.org/docs/web/getting-started"&gt;&lt;span style="color: #0000ff; font-family: Calibri; font-size: small;"&gt;http://csharpsdk.org/docs/web/getting-started&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://developers.facebook.com/docs/"&gt;&lt;span style="color: #0000ff; font-family: Calibri; font-size: small;"&gt;http://developers.facebook.com/docs/&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Creation of that web part is not a part of this blog post. &lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;We have solved it by creating a login button that will make facebook generate an access_token on behalf of the end user. Such access_tokens should not be sent over the network unencrypted.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/1882.Image5.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/1882.Image5.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Create an image to be used as the Ad&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;We need an image to be displayed as the Ad. In this example I&amp;rsquo;ve used an image of a Windows mobile 7.5 phone, and added some text to it. Place the image in the &lt;strong&gt;Image library&lt;/strong&gt; in the publishing site collection. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/5488.Image6.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/5488.Image6.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Create a Query Rule that will activate on users from Norway&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The goal is to have the Query Rule to be activated by end users having registered their country of origin in Facebook to be Norway. When activated, the Query Rule shall place an Ad (the image placed in the Image library) at the top of every category page.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;In the publishing site collection in &lt;strong&gt;Site Settings&lt;/strong&gt;, navigate to &lt;strong&gt;Site Collection Administration=&amp;gt; Search Query Rules. &lt;/strong&gt;Select your &lt;strong&gt;product catalog&lt;/strong&gt; as source, before clicking on N&lt;strong&gt;ew Query Rule.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/5164.Image7.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/5164.Image7.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Set &lt;strong&gt;Rule Name:&lt;/strong&gt; &lt;strong&gt;Mobile Ad for users from Norway.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Click on &lt;strong&gt;Context&lt;/strong&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Under the section &lt;strong&gt;Query is performed by these user segments&lt;/strong&gt;, click the radio button &amp;ldquo;&lt;strong&gt;One of these user segments&lt;/strong&gt;&amp;rdquo;. Then click &lt;strong&gt;Add user segment.&lt;/strong&gt; From the Import UI that pops up, navigate to &lt;strong&gt;Managed Metadata Service &lt;/strong&gt;=&amp;gt; &lt;strong&gt;Site Collection&lt;/strong&gt; =&amp;gt; &lt;strong&gt;User Segments =&amp;gt; Location &lt;/strong&gt;and choose the &lt;strong&gt;Norway &lt;/strong&gt;term.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/4403.Image8.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/4403.Image8.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Then give the User Segment the name &lt;strong&gt;User Location Norway.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/4010.Image9.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/4010.Image9.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;You have now mapped the Query Rule to the User Segment called &lt;strong&gt;User Location Norway&lt;/strong&gt;, that again is mapped to the User segment &lt;strong&gt;Term&lt;/strong&gt; Norway, which contains the value &lt;strong&gt;Norway, &lt;/strong&gt;which again can be &lt;strong&gt;matched&lt;/strong&gt; (by the custom web part) with the &lt;strong&gt;location data &lt;/strong&gt;returned from Facebook&lt;strong&gt;. &lt;/strong&gt;In other words; the query rule will execute on end-users from Norway.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;Note:&lt;/strong&gt; Under the section &lt;strong&gt;Query conditions:&lt;/strong&gt; click on &lt;strong&gt;Remove Condition, &lt;/strong&gt;as this Query Rule is not to be triggered by any (manuel) query.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/2313.Image10.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/2313.Image10.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;We now have to set the &lt;strong&gt;Actions&lt;/strong&gt; performed by the Query Rule. &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Under the section &lt;strong&gt;Actions&lt;/strong&gt;, click on &lt;strong&gt;Add promoted result.&lt;/strong&gt;&amp;nbsp; Type &lt;strong&gt;Mobile campaign&lt;/strong&gt; in the text box for &lt;strong&gt;Title&lt;/strong&gt;, and insert the &lt;strong&gt;URL&lt;/strong&gt; of the image to be displayed as the Ad in the text box for &lt;strong&gt;URL&lt;/strong&gt;. This is the URL to the image placed in the Image library. Select the checkbox &lt;strong&gt;Render the URL as a banner instead of a hyperlink.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/0763.Image11.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/300x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/0763.Image11.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Then click &lt;strong&gt;Save.&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The Query Rule definition now looks like this:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/8357.Image12.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/8357.Image12.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Click on &lt;strong&gt;Save&lt;/strong&gt; to store the Query Rule.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Add a web part to the category page for displaying the Ad&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;In this section we shall add another web part at the top of the category page, to display our Ad.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;Navigate&lt;/strong&gt; to a category page, click on &lt;strong&gt;Edit page&lt;/strong&gt; and &lt;strong&gt;Edit page template.&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Click on &lt;strong&gt;Add a Web Part&lt;/strong&gt; in the top section of the page. Select a &lt;strong&gt;Content search web part&lt;/strong&gt; from the &lt;strong&gt;Content Rollup&lt;/strong&gt; category. (you can also use your custom web part if that is based on a Content search web part) From the drop down menu in the upper right corner of the web part, click &lt;strong&gt;Edit Web Part.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Expand the &lt;strong&gt;Display Templates&lt;/strong&gt; section. Under &lt;strong&gt;Control&lt;/strong&gt; choose &lt;strong&gt;List. &lt;/strong&gt;Under &lt;strong&gt;Item&lt;/strong&gt; choose &lt;strong&gt;Large picture.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Expand the &lt;strong&gt;Property mappings &lt;/strong&gt;section&lt;strong&gt;.&lt;/strong&gt; &lt;strong&gt;Select&lt;/strong&gt; the checkbox for &amp;ldquo;&lt;strong&gt;Change the mapping of managed properties for the fields in the Item Display Template&amp;rdquo;&lt;/strong&gt;. In the Field &lt;strong&gt;Picture URL&lt;/strong&gt; type &lt;strong&gt;URL&lt;/strong&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Expand the section &lt;strong&gt;Settings, &lt;/strong&gt;and in the drop down menu for &lt;strong&gt;Query results provided by&lt;/strong&gt;, select the web part that this web part shall get its result from. In other words, select the custom target content search web part that is used on that category page. In the same section in the drop down menu for &lt;strong&gt;Result table, &lt;/strong&gt;select&lt;strong&gt; SpecialTermResults. &lt;/strong&gt;This is the result set where the Ad is placed by the Query Rule.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The respective sections in the web part editor shall now look like this.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/5543.Image13.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/250x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/5543.Image13.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Click &lt;strong&gt;OK&lt;/strong&gt; to save the configuration&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Verify the end result&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Navigate to one of your category pages. Log into the web site using the &lt;strong&gt;Login with Facebook&lt;/strong&gt; button. Users, with their location set to Norway in Facebook, will now see the Ad on top of &lt;strong&gt;any&lt;/strong&gt; category page:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/6523.Image14.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/6523.Image14.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA;" lang="EN-US"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #000000; font-family: Calibri; font-size: x-small;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10369248" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/tags/SharePoint+2013/">SharePoint 2013</category><category domain="http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/tags/search/">search</category><category domain="http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/tags/user+segmentation/">user segmentation</category><category domain="http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/tags/adaptive+experiences/">adaptive experiences</category><category domain="http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/tags/targeted+content/">targeted content</category></item><item><title>Set up User Segmentation to drive adaptive experiences in a Product Catalog in SharePoint 2013</title><link>http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/2012/11/14/set-up-user-segmentation-to-drive-adaptive-experiences-in-a-product-catalog-in-sharepoint-2013.aspx</link><pubDate>Wed, 14 Nov 2012 14:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10368508</guid><dc:creator>Anders Fagerhaug (PM)</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/rsscomments.aspx?WeblogPostID=10368508</wfw:commentRss><comments>http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/2012/11/14/set-up-user-segmentation-to-drive-adaptive-experiences-in-a-product-catalog-in-sharepoint-2013.aspx#comments</comments><description>&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Adaptive Experience is about tailoring the user experience in order to better match the interests of the end user. This can have a great effect on sales, since a better match between products and user needs increases the chance of a sale. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Let&amp;rsquo;s take a look at the following scenario:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Pete Smith owns an online store selling electrical consumer goods. New Windows mobile 8 phones have arrived recently, and Pete wants to promote one of these phones to the customers he believes is interested in the state of the art products. He decides to bring this product to attention to all end users using Internet Explorer 10 as their browser, as he thinks people using the state of the art browsers, are interested in state of the art mobile phones. In order to differentiate between end users, he divides them into different user segments and gives the different user segments a different user experience. While those end users running Internet Explorer 10 will get an Ad displaying one of the newest Windows mobile&amp;nbsp; phones in stock, end users running on older versions will not see this particular campaign. They may be offered other products (but that is not a part of this example). &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;By segmenting his users and giving different user experiences to different end users, Pete is able to tailor his market campaigns towards different users at the same time. He could segment his users by numerous things; location, gender, age, etc&amp;nbsp; as long as he has this data available. &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;This blog post describes how to set up user segmentation based on browser type, and how we can change the user experience in a product catalog by the use of Query Rules. The only custom made part in this example is the web part &amp;nbsp;which is fetching the end user browser data and matching it with custom properties in the user segments we are setting up. I will give code examples on the most important parts of such a web part. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;strong&gt;&lt;span style="color: #000000; font-family: Calibri;"&gt;Topics covered in this blog:&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="color: #000000; font-family: Calibri; font-size: small;"&gt;This is how it&amp;rsquo;s working&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: #000000; font-family: Calibri; font-size: small;"&gt;Prerequisites&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: #000000; font-family: Calibri; font-size: small;"&gt;Create a term set defining the User Segments.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: #000000; font-family: Calibri; font-size: small;"&gt;Create a custom web part that fetches the User Agent String&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: #000000; font-family: Calibri; font-size: small;"&gt;Create an image to be used as the Ad&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: #000000; font-family: Calibri; font-size: small;"&gt;Create a Query Rule that will activate on User Segment IE10&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: #000000; font-family: Calibri; font-size: small;"&gt;Add a web part to the category page for displaying the Ad&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: #000000; font-family: Calibri; font-size: small;"&gt;Verify the end result&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;This is how it&amp;rsquo;s working&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/2804.Image-1.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/2804.Image-1.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The end user is doing a page request towards the web site, and is at the same time sending its &lt;strong&gt;User Agent String&lt;/strong&gt; with this request. The custom web part (web part 2) extracts the &lt;strong&gt;User Agent String value (MSIE 10.0)&lt;/strong&gt; and matches it against&lt;strong&gt; Custom Properties&lt;/strong&gt; for &lt;strong&gt;User Segment Terms&lt;/strong&gt; in the term set. When matching, the relevant &lt;strong&gt;User Segment name (IE10) &lt;/strong&gt;is added as a parameter to the &lt;strong&gt;search query&lt;/strong&gt; which is sent to the index to fetch items to be presented in web part 2. A&lt;strong&gt; Query Rule &lt;/strong&gt;monitors the search queries, and activates when the search parameter &lt;strong&gt;User Segment=IE10&lt;/strong&gt;. The Query Rule is configured to return a search result (the Ad), to the web part sending the query in the first place. The Ad is a part of the resultset &lt;strong&gt;SpecialTermResults. &lt;/strong&gt;Another web part (web part 1) is added to the web site in order to display the Ad (Promotion). This web part does not send out search queries, but fetches results from web part 2. The resultset &lt;strong&gt;SpecialTermResult&lt;/strong&gt; is fetched. This contains the Ad sent from the &lt;strong&gt;Query Rule&lt;/strong&gt;, and consists of a &lt;strong&gt;Title&lt;/strong&gt; and an &lt;strong&gt;URL&lt;/strong&gt; to the image to be promoted. Web part 2 can now display the Ad for the new Windows mobile phone.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Prerequisites&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;A Product catalog site collection has been created.&lt;/span&gt;&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;A list of products has been created&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Navigation term set is created&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Products list is shared with publishing site collection using XSP.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;A publishing site collection has been created.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The web site is build up by a category page, and an item details page to display the items.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The site collection is available to anonymous users&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Skills to create a custom web part in Visual Studio and deploy it in SharePoint as a Solution&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Let&amp;rsquo;s see how all the different parts are configured to get this scenario working.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Create a term set defining the User Segments.&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;On your publishing site, in SharePoint, navigate to &lt;strong&gt;Site Settings=&amp;gt; Term store management =&amp;gt;&lt;/strong&gt; &lt;strong&gt;Taxonomy term store&lt;/strong&gt;. In the &lt;strong&gt;Taxonomy Term Store&lt;/strong&gt; navigation pane at the left, navigate to &lt;strong&gt;Managed Metadata Service =&amp;gt; Site collection&lt;/strong&gt; (the one mapped to the product catalog site collection). &lt;strong&gt;Create a new term set (User Segments).&lt;/strong&gt; Then create the term &lt;strong&gt;Browser Type&lt;/strong&gt;, and the child terms &lt;strong&gt;IE8, IE9&lt;/strong&gt;, &lt;strong&gt;IE10.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/2350.Image-2.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/250x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/2350.Image-2.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;For each child term in the &lt;strong&gt;Browser Type&lt;/strong&gt; term set, click on &lt;strong&gt;Custom Properties&lt;/strong&gt; tab, and add unique properties for that user segment in the &lt;strong&gt;Shared Properties&lt;/strong&gt; section.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Shared Property Name:&lt;strong&gt; UserAgent&lt;/strong&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Value: Set the &lt;strong&gt;User Agent String &lt;/strong&gt;for that particular browser type. E.g. for user segment term &lt;strong&gt;IE10&lt;/strong&gt;,&lt;strong&gt; Value= MSIE 10.0. &lt;/strong&gt;For user segment&lt;strong&gt; IE9, value=MSIE 9.0, etc&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/5850.Image-3.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/5850.Image-3.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Create a custom web part that fetches the User Agent String&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;You will have to create your own custom solution in Visual Studio. This project is called SPCDemoWebParts. The custom web part you are creating has to be a part of this solution.&lt;span style="font-family: Times New Roman; font-size: small;"&gt; In Visual Studio give the custom web part at title and in which&amp;nbsp;group the web part will end up in.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;This web part will be a modified &lt;strong&gt;ContentBySearchWebPart&lt;/strong&gt;. This is done by sub-classing the ContentBySearchWebPart and adding the methods described below.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style="width: 100%;" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;td&gt;&amp;nbsp; &lt;em&gt;&amp;hellip;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;using&amp;nbsp;Microsoft.SharePoint;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;using&amp;nbsp;Microsoft.SharePoint.Taxonomy;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;using&amp;nbsp;Microsoft.Office.Server.Search.WebControls;&lt;/em&gt;&amp;nbsp;
&lt;div&gt;
&lt;p&gt;&lt;em&gt;namespace&amp;nbsp;SPCDemoWebParts.TargetedContentSearch&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;{&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[ToolboxItemAttribute(false)]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;partial&amp;nbsp;class&amp;nbsp;TargetedContentSearch&amp;nbsp;:&amp;nbsp;ContentBySearchWebPart&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;hellip;&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/td&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/tr&gt;
&amp;nbsp;&amp;nbsp;&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Note that you will also need to add some references to required assemblies for your project&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/8117.Image-13.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/350x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/8117.Image-13.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;In addition to show content by search, it will also fetch the &lt;strong&gt;UserAgent string&lt;/strong&gt; given by the end user. The web part will then split the user agent string into parts, and check each part for a matching &lt;strong&gt;custom property&lt;/strong&gt; in the term store.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style="width: 100%;" cellspacing="0" cellpadding="0"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;div&gt;
&lt;pre&gt;&lt;em&gt;private&amp;nbsp;void&amp;nbsp;AddUserAgentSegmentTerms(List&amp;lt;string&amp;gt;&amp;nbsp;userSegmentTerms)&lt;br /&gt;&lt;/em&gt;&lt;em&gt;{&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SPSite&amp;nbsp;site&amp;nbsp;=&amp;nbsp;SPContext.Current.Site;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TaxonomySession&amp;nbsp;session&amp;nbsp;=&amp;nbsp;new&amp;nbsp;TaxonomySession(site);&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TermStore&amp;nbsp;defaultSiteCollectionStore&amp;nbsp;=&amp;nbsp;session.DefaultSiteCollectionTermStore;&lt;/em&gt;&lt;/pre&gt;
&lt;pre&gt;&amp;nbsp;&lt;br /&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;userAgentparts&amp;nbsp;=&amp;nbsp;Page.Request.UserAgent.Split(new&amp;nbsp;char[]&amp;nbsp;{&amp;nbsp;';',&amp;nbsp;'(',&amp;nbsp;')'&amp;nbsp;});&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach&amp;nbsp;(var&amp;nbsp;part&amp;nbsp;in&amp;nbsp;userAgentparts)&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;entry&amp;nbsp;=&amp;nbsp;part.Trim();&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;terms&amp;nbsp;=&amp;nbsp;termStore.GetTermsWithCustomProperty("UserAgent",&amp;nbsp;entry,&amp;nbsp;false);&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(terms.Count&amp;nbsp;&amp;gt;&amp;nbsp;0)&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;userSegmentTerms.Add(terms[0].Id.ToString());&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/em&gt;&lt;em&gt;}&lt;/em&gt;&lt;/pre&gt;
&lt;/div&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/td&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/tr&gt;
&amp;nbsp;&amp;nbsp;&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Thus the code will split a User Agent String such as "&lt;strong&gt;Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0&lt;/strong&gt;)" into the list { "Mozilla/5.0", "compatible", "MSIE 10.0", "Windows NT 6.1", "Trident/6.0" } and then check the term store for any matching custom property.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The &lt;strong&gt;GUID&lt;/strong&gt;s of any matching terms &lt;strong&gt;will then be added to the search query&lt;/strong&gt; for fetching products. This is done by adding the list of GUIDs to the &lt;strong&gt;UserSegmentTerms&lt;/strong&gt; property of the &lt;strong&gt;DataProviderWebPart&lt;/strong&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style="width: 100%;" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;div&gt;
&lt;pre&gt;&lt;em&gt;private&amp;nbsp;void&amp;nbsp;AddMycustomProperties(object&amp;nbsp;sender,&amp;nbsp;BeforeSerializeToClientEventArgs&amp;nbsp;e)&lt;br /&gt;&lt;/em&gt;&lt;em&gt;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DataProviderScriptWebPart&amp;nbsp;dataProvider&amp;nbsp;=&amp;nbsp;sender&amp;nbsp;as&amp;nbsp;DataProviderScriptWebPart;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;List&amp;lt;string&amp;gt;&amp;nbsp;userSegmentTerms&amp;nbsp;=&amp;nbsp;new&amp;nbsp;List&amp;lt;string&amp;gt;();&lt;br /&gt;&lt;/em&gt;&amp;nbsp;&lt;br /&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AddUserAgentSegmentTerms(userSegmentTerms);&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dataProvider.Properties["UserSegmentTerms"]&amp;nbsp;=&amp;nbsp;userSegmentTerms.ToArray();&lt;br /&gt;&lt;/em&gt;&lt;em&gt;}&lt;/em&gt;&lt;/pre&gt;
&lt;/div&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/td&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/tr&gt;
&amp;nbsp;&amp;nbsp;&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;All that now remains is to stitch the AddMycustomProperties into the OnLoad method of the web part, so it&amp;rsquo;s called before the page is rendered.&lt;/p&gt;
&lt;table style="width: 100%;" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;div&gt;
&lt;pre&gt;&lt;em&gt;protected&amp;nbsp;override&amp;nbsp;void&amp;nbsp;OnLoad(EventArgs&amp;nbsp;e)&lt;br /&gt;&lt;/em&gt;&lt;em&gt;{&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(this.AppManager&amp;nbsp;!=&amp;nbsp;null)&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(this.AppManager.QueryGroups.ContainsKey(this.QueryGroupName)&amp;nbsp;&amp;amp;&amp;amp;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.AppManager.QueryGroups[this.QueryGroupName].DataProvider&amp;nbsp;!=&amp;nbsp;null)&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.AppManager.QueryGroups[this.QueryGroupName].DataProvider.BeforeSerializeToClient&amp;nbsp;+=&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new&amp;nbsp;BeforeSerializeToClientEventHandler(AddMycustomProperties);&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;base.OnLoad(e);&lt;br /&gt;&lt;/em&gt;&lt;em&gt;}&lt;/em&gt;&lt;/pre&gt;
&lt;/div&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/td&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/tr&gt;
&amp;nbsp;&amp;nbsp;&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The same method can easily be used for segmenting users in other ways based on browsing history or login information.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The custom web part created&amp;nbsp;is packaged as a solution with a .wsp extention.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;You will have to upload the solution into&amp;nbsp;the Public site Collection, and use it when setting up the category page, to display items in a category.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;&lt;span style="font-size: small;"&gt;&lt;span style="color: #4f81bd;"&gt;&lt;span style="font-family: Cambria;"&gt;Upload the custom web part as a solution&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Assuming the .wsp file is placed in C:\Temp\MyCustomWebPart.ws&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Start &amp;laquo;SharePoint&amp;raquo; 2013 Management Shell as Administrator&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Run: &lt;strong&gt;&lt;em&gt;Add-SPSolution -LiteralPath C:\temp\MyCustomWebPart.wsp&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;em&gt;Run:&lt;strong&gt; Install-SPSolution -identity MyCustomWebPart.wsp -GACDeployment &amp;ndash;AllWebApplications&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;In the publishing site collection, navigate to &lt;strong&gt;Site settings=&amp;gt; Site collection Administration =&amp;gt; Site collection features: &amp;nbsp;&lt;/strong&gt;Deactivate and activate site collection feature "&lt;strong&gt;Adaptive Experiences WebParts&lt;/strong&gt;"&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Create an image to be used as the Ad&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;We need an image to be displayed as the Ad. In this example I&amp;rsquo;ve used an image of a Windows mobile phone, and added some text to it. Place the image in the &lt;strong&gt;Image library&lt;/strong&gt; in the publishing site collection. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/2783.Image-4.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/2783.Image-4.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Create a Query Rule that will activate on User Segment IE10&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The goal is to have the Query Rule to be activated by end users using the &amp;nbsp;browser Internet Explorer 10. When activated the Query Rule shall place an Ad (the image placed in the Image library) at the top of every category page.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;In the publishing site collection in &lt;strong&gt;Site Settings&lt;/strong&gt;, navigate to &lt;strong&gt;Site Collection Administration=&amp;gt; Search Query Rules. &lt;/strong&gt;Select your &lt;strong&gt;product catalog&lt;/strong&gt; as source, before clicking on N&lt;strong&gt;ew Query Rule.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/5516.Image-5.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/5516.Image-5.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Set &lt;strong&gt;Rule Name:&lt;/strong&gt; &lt;strong&gt;Mobile Ad for IE10 users.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Click on &lt;strong&gt;Context&lt;/strong&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Under the section &lt;strong&gt;Query is performed by these user segments&lt;/strong&gt;, click the radio button &amp;ldquo;&lt;strong&gt;One of these user segments&lt;/strong&gt;&amp;rdquo;. Then click &lt;strong&gt;Add user segment.&lt;/strong&gt; From the Import UI that pops up, navigate to &lt;strong&gt;Managed Metadata Service &lt;/strong&gt;=&amp;gt; &lt;strong&gt;Site Collection&lt;/strong&gt; =&amp;gt; &lt;strong&gt;User Segments =&amp;gt; Browser Type &lt;/strong&gt;and choose the &lt;strong&gt;IE10 &lt;/strong&gt;term.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/4466.Image-6.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/400x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/4466.Image-6.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Then give the User Segment the name &lt;strong&gt;Internet Explorer 10&lt;/strong&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/2235.Image-7.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/300x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/2235.Image-7.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;You have now mapped the Query Rule to the User Segment called Internet Explorer 10, that again is mapped to the User segment &lt;strong&gt;Term&lt;/strong&gt; IE10, which contains the value &lt;strong&gt;MSIE 10.0, &lt;/strong&gt;which again can be &lt;strong&gt;matched&lt;/strong&gt; (by the custom web part) with the &lt;strong&gt;User Agent String &lt;/strong&gt;returned from the&lt;strong&gt; end-user. &lt;/strong&gt;In other words; the query rule will execute on end-users running on Internet Explorer 10.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;Note:&lt;/strong&gt; Under the section &lt;strong&gt;Query conditions:&lt;/strong&gt; click on &lt;strong&gt;Remove Condition, &lt;/strong&gt;as this Query Rule is not to be triggered by any (manuel) query.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/7242.Image-8.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/7242.Image-8.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;We now have to set the &lt;strong&gt;Actions&lt;/strong&gt; performed by the Query Rule. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Under the section &lt;strong&gt;Actions&lt;/strong&gt;, click on &lt;strong&gt;Add promoted result.&lt;/strong&gt;&amp;nbsp; Type &lt;strong&gt;Mobile campaign&lt;/strong&gt; in the text box for &amp;nbsp;&lt;strong&gt;Title&lt;/strong&gt;, and insert the &lt;strong&gt;URL&lt;/strong&gt; of the image to be displayed as the Ad in the text box for &lt;strong&gt;URL&lt;/strong&gt;. Thuis is the URL to the image placed in the Image library. Select the checkbox &lt;strong&gt;Render the URL as a banner instead of a hyperlink.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/1263.Image-9.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/300x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/1263.Image-9.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Then click &lt;strong&gt;Save.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The Query Rule definition now looks like this:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/1563.Image-10.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/1563.Image-10.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Click on &lt;strong&gt;Save&lt;/strong&gt; to store the Query Rule.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Add a web part to the category page for displaying the Ad&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;In this section we shall add another web part at the top of the category page, to display our Ad.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;strong&gt;Navigate&lt;/strong&gt; to a category page, click on &lt;strong&gt;Edit page&lt;/strong&gt; and &lt;strong&gt;Edit page template.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Click on &lt;strong&gt;Add a Web Part&lt;/strong&gt; in the top section of the page. Select a &lt;strong&gt;Content search web part&lt;/strong&gt; from the &lt;strong&gt;Content Rollup&lt;/strong&gt; category. (you can also use your custom web part if that is based on a Content search web part) From the drop down menu in the upper right corner of the web part, click &lt;strong&gt;Edit Web Part.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Expand the &lt;strong&gt;Display Templates&lt;/strong&gt; section. Under &lt;strong&gt;Control&lt;/strong&gt; choose &lt;strong&gt;List. &lt;/strong&gt;Under &lt;strong&gt;Item&lt;/strong&gt; choose &lt;strong&gt;Large picture.&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Expand the &lt;strong&gt;Property mappings &lt;/strong&gt;section&lt;strong&gt;.&lt;/strong&gt; &lt;strong&gt;Select&lt;/strong&gt; the checkbox for &amp;ldquo;&lt;strong&gt;Change the mapping of managed properties for the fields in the Item Display Template&amp;rdquo;&lt;/strong&gt;. In the Field &lt;strong&gt;Picture URL&lt;/strong&gt; type &lt;strong&gt;URL&lt;/strong&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Expand the section &lt;strong&gt;Settings, &lt;/strong&gt;and in the drop down menu for &lt;strong&gt;Query results provided by&lt;/strong&gt;, select the web part that this web part shall get its result from. In other words, select the custom target content search web part that is used on that category page. In the same section in the drop down menu for &lt;strong&gt;Result table, &lt;/strong&gt;select&lt;strong&gt; SpecialTermResults. &lt;/strong&gt;This is the result set where the Ad is placed by the Query Rule.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;The respective sections in the web part editor shall now look like this.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/5722.Image-11.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/300x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/5722.Image-11.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Click &lt;strong&gt;OK&lt;/strong&gt; to save the configuration.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="color: #4f81bd; font-family: Cambria; font-size: medium;"&gt;Verify the end result&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Navigate to one of your category pages. By using an Internet Browser 10, you will now see the Ad on top of &lt;strong&gt;any&lt;/strong&gt; category page:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/7457.Image-12.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-70/7457.Image-12.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;br /&gt; &lt;br /&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;br /&gt;&amp;nbsp; &lt;br /&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10368508" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/tags/SharePoint+2013/">SharePoint 2013</category><category domain="http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/tags/search/">search</category><category domain="http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/tags/user+segmentation/">user segmentation</category><category domain="http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/tags/Product+catalog/">Product catalog</category><category domain="http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/tags/adaptive+experiences/">adaptive experiences</category></item></channel></rss>