private void TriggerGoal(SubscribeModel subscription)
        {
            var             goalId         = Guid.Empty;
            IGoalDefinition goalDefinition = null;

            if (Guid.TryParse(subscription.GoalId, out goalId))
            {
                using (new Sitecore.SecurityModel.SecurityDisabler())
                {
                    IDefinitionManager <IGoalDefinition> goalDefinitionManager = ServiceLocator.ServiceProvider.GetDefinitionManagerFactory().GetDefinitionManager <Sitecore.Marketing.Definitions.Goals.IGoalDefinition>();
                    goalDefinition = goalDefinitionManager.Get(goalId, System.Globalization.CultureInfo.InvariantCulture);

                    if (goalDefinition != null)
                    {
                        //Trigger Goal on last page in the tracker. (May be incorrect if visitor is in multiple tabs)
                        var page = Tracker.Current.Interaction.PreviousPage;
                        page.RegisterGoal(goalDefinition);
                    }
                    else
                    {
                        Sitecore.Diagnostics.Log.Warn("Goal: [" + subscription.GoalId + "] Not Defined", this);
                    }
                }
            }
            else
            {
                Sitecore.Diagnostics.Log.Warn("Goal: [" + subscription.GoalId + "] Can Not be Parsed", this);
            }
        }
        public void TrackOutcome(Guid outComeDefinitionId, string currencyCode, decimal monetaryValue)
        {
            Assert.ArgumentNotNull(outComeDefinitionId, nameof(outComeDefinitionId));

            if (!IsActive || Tracker.Current.Contact == null)
            {
                return;
            }

            var outcomeDefinition = _outcomeDefinitionManager.Get(outComeDefinitionId, CultureInfo.InvariantCulture);

            if (outcomeDefinition == null)
            {
                Log.Warn($"Cannot find outcome: {outComeDefinitionId}", this);
                return;
            }

            Tracker.Current.CurrentPage.RegisterOutcome(outcomeDefinition, currencyCode, monetaryValue);
        }
        public void TrackGoal(Guid goalId, string text = null, string data = null, string dataKey = null, int?value = null)
        {
            Assert.ArgumentNotNull(goalId, nameof(goalId));

            if (!IsActive)
            {
                return;
            }

            var goalDefinition = _goalDefinitionManager.Get(goalId, CultureInfo.InvariantCulture);

            if (goalDefinition == null)
            {
                Log.Warn($"Cannot find goal: {goalId}", this);
                return;
            }

            var eventData = Tracker.Current.CurrentPage.RegisterGoal(goalDefinition);

            if (data != null)
            {
                eventData.Data = data;
            }

            if (dataKey != null)
            {
                eventData.DataKey = dataKey;
            }

            if (text != null)
            {
                eventData.Text = text;
            }

            if (value != null)
            {
                eventData.Value = value.Value;
            }
        }
Exemplo n.º 4
0
        private ICampaignActivityDefinition GetCampaignDefinition(Guid campaignId)
        {
            var campaign = campaignDefinitionManager.Get(campaignId, Context.Language.CultureInfo) ?? campaignDefinitionManager.Get(campaignId, CultureInfo.InvariantCulture);

            return(campaign);
        }
Exemplo n.º 5
0
 private IOutcomeDefinition GetOutcomeDefinition(Guid outcomeId)
 {
     return(outcomeDefinitionManager.Get(outcomeId, Context.Language.CultureInfo) ?? outcomeDefinitionManager.Get(outcomeId, CultureInfo.InvariantCulture));
 }
 public IPageEventDefinition GetGoalDefinition(Guid goalId)
 {
     return(pageEventDefinitionManager.Get(goalId, Context.Language.CultureInfo) ?? pageEventDefinitionManager.Get(goalId, CultureInfo.InvariantCulture));
 }