2

I am implementing Smart Target 2014 with DD4T Framework as per the approach in this article http://www.tridiondeveloper.com/dd4t-and-sdl-smarttarget-2014-integration. I have done following steps to create a sample page:

  1. Created and configured promotion/Trigger inside SDL tridion using Targeting option. Trigger type is of Current Date.
  2. Added markup on DD4T Page view for smart target region as below:

    <!-- Start Promotion Region: { "RegionID": "Header" } -->
    @Html.RenderSmartTargetRegionUsingView("Header", "General")
    <!-- End SiteEdit Promotional Region -->
    

Where Region is Header and my Component view is General.

  1. Used AmbientDataHelper to fetch trigger using mbientDataHelper.GetTriggers(claimStore) . Complete code is:
ClaimStore claimStore = AmbientDataContext.CurrentClaimStore;
string query = AmbientDataHelper.GetTriggers(claimStore);
var queryBuilder = new QueryBuilder();
queryBuilder.Parse(query);
if (maxItems > 0)
{
  queryBuilder.MaxItems = maxItems;
}
queryBuilder.StartIndex = startIndex;
var pubIdUri = new Tridion.SmartTarget.Utils.TcmUri(publicationId);
Tridion.SmartTarget.Query.Builder.PublicationCriteria pubCriteria
= new Tridion.SmartTarget.Query.Builder.PublicationCriteria(pubIdUri);
queryBuilder.AddCriteria(pubCriteria);
RegionCriteria region = new RegionCriteria(regionName);
List<string> componentIds = new List<string>();
ResultSet fredHopperResultset = queryBuilder.Execute();
foreach (Promotion p in fredHopperResultset.Promotions)
{
 foreach (Item i in p.Items)
 {
    componentIds.Add(i.ComponentUriAsString + "|" + i.TemplateUriAsString);
 }
}
foreach (string s in componentIds)
{
  string[] compPresIds = s.Split(new char[] { '|' });
  string compId = compPresIds[0], templateId = compPresIds[1];
  IComponent comp = null;
  ComponentFactory cf = new ComponentFactory();
  cf.TryGetComponent(compId, out comp, templateId);
  var renderedCp = helper.Partial(viewName, comp);
  renderedRegionItemsList.Add(renderedCp);
}
return renderedRegionItemsList;

I have observed that AmbientDataHelper.GetTriggers(claimStore) is return empty string value. Can anyone suggest what I am missing.

2

The problem is likely that the triggers that your Promotion depends on are not in the query (which is logged as INFO, by the way), or there's a problem with getting the trigger values from the ADF.

Since you said the trigger is Current Date, that's a default trigger so there must be other factors preventing it. Maybe your region is incorrect, or you're not in the right Publication.

You could try setting the triggers in XPM (using footprints) and seeing if your Promotion shows up there. Also keep in mind that the Component Presentation(s) returned by the Promotion need to be published and available on the website.

  • Hi Peter, The query shown in log is: INFO Query - Executing query: fh_location=//catalog01/en_US&fh_start_index=0&st_publication=tcm%3A0-7-1. I can see that result of AmbientDataHelper.GetTriggers(claimStore) is empty string. So it is sure that ADF is not able to fetch the trigger. Region I have used is header, which is again a default region. Is there any setting required for region in my application apart from markup added in page view? Do you see any issue in code which I am using to render promotion on my page? – Mukesh Kumar Sep 5 '14 at 18:23
  • 1
    That query doesn't have the region in it, so it will never trigger. I see that you create a RegionCriteria in the code, but you don't appear to add it to the Query Builder -- which might be the cause of this problem. As for GetTriggers not returning anything, there's a couple of potential reasons. You might not have the SmartTarget cartridge running, you might not have configured the prefixes correctly, or you might just not have any triggers in FH that correspond to the triggers currently in the ADF. – Peter Kjaer Sep 8 '14 at 9:35
1

AmbientDataHelper.GetTriggers(claimStore) depends on the SmartTarget config for your website as explained in the docs here: http://sdllivecontent.sdl.com/LiveContent/content/en-US/SDL_SmartTarget_2014-v1/GUID-0071E368-984B-43DD-94C9-726727B5BD5B and you need to make sure you have the smarttarget_cartridge.jar file present in your website's bin/lib directory (among other jars required as explained in the docs).

Make sure that your website is configured for SmartTarget and logging is enabled (also in the docs) so that you can see what the exact problem is.

  • Hi Nickoli, There is no error in smart target log. Below are the log message showing there is no promotion available in Fredhopper. DEBUG Query - Query returned 10 item(s) DEBUG Query - Query returned 0 promotion(s): I have created promotion in SDL. I think it is not available in fredhopper. Can anyone suggest, how will it move to Fredhopper server? How can we check if promotion is available in fredhopper? – Mukesh Kumar Sep 5 '14 at 14:16
  • SmartTarget stores the Promotions in Fredhopper, so it's definitely there :) You will not see them in the Business Manager by default, because editing them there is likely to result in data loss. – Peter Kjaer Sep 5 '14 at 14:36
  • 1
    Thanks to all, Issue has been fixed now. Issue was with configuration of ambient data framework. – Mukesh Kumar Sep 9 '14 at 7:24
  • Hi mukesh I am also facing the same challenge while implementing the samrttarget with dd4t can you please let me know what configuration of ambient data framework is required as i have followed the docs.sdl.com/LiveContent/content/en-US/… to configure the same – Hem Kant Feb 5 '15 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.