public object ComputeFieldValue(IIndexable indexable) { Item i = ((Item)(indexable as SitecoreIndexableItem)); if (i != null && i["__Tracking"] != String.Empty) { TrackingField field = new TrackingField(i.Fields["__Tracking"]); ContentProfile[] profiles = field.Profiles; List <ID> presets = new List <ID>(); foreach (ContentProfile profile in profiles) { if (profile.Presets != null) { foreach (var a in profile.Presets) { foreach (Item card in profile.GetProfileItem().Axes.GetDescendants()) { if (card.Key == a.Key && card.Template.Key.StartsWith("profile card")) { presets.Add(card.ID); } } } } } return(presets); } return(string.Empty); }
public object ComputeFieldValue(IIndexable indexable) { Item i = ((Item)(indexable as SitecoreIndexableItem)); if (i != null && i["__Tracking"] != String.Empty) { TrackingField field = new TrackingField(i.Fields["__Tracking"]); ContentProfile[] profiles = field.Profiles; List<ID> presets = new List<ID>(); foreach (ContentProfile profile in profiles) { if (profile.Presets != null) { foreach (var a in profile.Presets) { foreach (Item card in profile.GetProfileItem().Axes.GetDescendants()) { if (card.Key == a.Key && card.Template.Key.StartsWith("profile card")) presets.Add(card.ID); } } } } return presets; } return string.Empty; }
protected string GetTrackingFieldPageId(TrackingField trackingField) { switch (trackingField) { case TrackingField.TnTCampaignId: return("_cstnt_cid"); case TrackingField.TnTExperienceId: return("_cstnt_eid"); } throw new Exception("trackingField page id not defined."); }
public void GetBetterTrackingFieldOnce() { // Arrange // Act Field field = item.Fields["__tracking"]; TrackingField trackingField = new TrackingField(field); Assert.IsTrue(trackingField != null); // Assert Console.WriteLine("Field value is: {0}", field.Value); }
private void SetPageProfileValues(AnalyticsDataModel data) { TrackingField trackingField = new TrackingField(Sitecore.Context.Item.Fields[Sitecore.Analytics.AnalyticsIds.TrackingField]); foreach (var profile in trackingField.Profiles) { data.ProfileValues.Add(new AnalyticsProfileValue() { ProfileName = profile.Name, ProfileId = profile.ProfileID.ToGuid(), Values = profile.Keys.ToDictionary(i => i.Name, i => i.Value).ToList() }); } }
public override void Process(ProcessItemArgs args) { Assert.ArgumentNotNull(args, "args"); var item = Context.Item; var taxonomyField = (MultilistField)item.Fields[ConfigSettings.TaxonomyField]; if (taxonomyField != null) { foreach (var tag in taxonomyField.GetItems()) { // assign tag Profiles to the context item TrackingField tagTrackingField = GetTagProfile(tag); if (tagTrackingField != null) { args.TrackingParameters.Add(tagTrackingField); } } } }
public void GetTrackingField() { // Arrange Stopwatch sw = new Stopwatch(); // Act sw.Start(); Field field = item.Fields["__tracking"]; for (var i = 0; i < 1000; i++) { TrackingField trackingField = new TrackingField(field); Assert.IsTrue(trackingField != null); } sw.Stop(); // Assert Console.WriteLine("Field value is: {0}", field.Value); Console.WriteLine("Took {0} ms", sw.ElapsedTicks); }
public void AssignContentProfile(Profile profile, string profileName) { if (Item == null) { return; } Field field = Item.Fields[trackingFieldName]; if (field == null) { return; } var trackingField = new TrackingField(field); ContentProfile contentProfile = trackingField.Profiles.FirstOrDefault(p => p.Name == profileName); if (contentProfile == null || !contentProfile.IsSavedInField) { return; } ContentProfile = contentProfile; }
public void SetPatternCard(string searchedTerm, string searchTermsRoot) { try { Sitecore.Data.Database db = Sitecore.Context.Database; var searchTermsRootItem = db.GetItem(searchTermsRoot); if (searchTermsRootItem != null) { //Get persona tag from Data folder matching the searched keyword var peronaDataTagsQuery = string.Format(searchTermsRootItem.Paths.FullPath + "//*[CompareCaseInsensitive(@Text,'{0}')]", searchedTerm); // TODO: Use search indexes if more search items . Item matchedPeronaTag = db.SelectSingleItem(peronaDataTagsQuery); if (matchedPeronaTag != null) { //Get all pattern cards which has matching persona tag as per searched keyword var query = string.Format("/sitecore/system/Marketing Control Panel/Profiles//*[@@templateid='{0}' and contains(@Related Search Terms,'{1}')]", "{4A6A7E36-2481-438F-A9BA-0453ECC638FA}", matchedPeronaTag.ID); Item[] allPatternCards = db.SelectItems(query); foreach (Item patternCard in allPatternCards) { TrackingField tField = new TrackingField(patternCard.Fields["Pattern"]); var listProfiles = tField.Profiles.Where(profile1 => profile1.IsSavedInField); if (listProfiles.Any()) { var scores = new Dictionary<string, float>(); foreach (ContentProfile profile in listProfiles) { if (Tracker.Current.Interaction != null) { //Set current profile with respective pattern var pageProfile = Tracker.Current.Interaction.Profiles[patternCard.Parent.Parent.Name]; foreach (var key in profile.Keys) { if (key.Value != 0) { // Value is increased by 3 times to add the profile to current Interaction ASAP. scores.Add(key.Name, key.Value * 3); } } pageProfile.Score(scores); pageProfile.UpdatePattern(); } } } } } } } catch (Exception ex) { Sitecore.Diagnostics.Log.Error("Error occured in SetPatternCard " + ex.ToString(), new Exception()); } }