Thursday, August 3, 2017

Auto populate Web form for marketers Form (WFFM) Fields With social data using social connected Sitecore 8+

In previous post i have shown you how to get the social data using social connected.


Now we will see how to auto populate these data to a web form for marketers Form Fields.

Prerequisite:-

  1. Sitecore 8+
  2. Web form for marketers module
  3. Social connected configured.
We will be fetching LinkedIn data to a WFFM form using LinkedIn Login.

Step1- Setting up WFFM form in page.

 For adding a form in page create a form item in sitecore.


Step2- Assign WFFM form to page and add LinkedIn login control


adding-wffm-form-sitecore





Step 3 - Configuring Form fields 

To set default value to a form field we can set Rules.
  • Click on form item go to form designer
  • Select any field and scroll to bottom of the left panel.
wffm-sitecore-field-rules


By default sitecore provides few default action.



default-actions-wffm-field





  • Hide element
  • Use value from query string
  • Use value from profiles specific field
  • Use value from specific visitor tag
But since we have to populate the social data we can not use above rules.
For populating social data we need to create a new rule.

Step 4- Creating new WFFM action rule.

  • Navigate to "/sitecore/system/Settings/Rules/Definitions/Elements/Web Forms for Marketers Actions"
  • Right click and insert new Action.
  • Provide your custom method and reference details. As below.
wffm-add-action-rule



wffm-new-action-created


Method- SCcustom.ReadPropertyFromMongo

using Sitecore.Security.Accounts;
using System;
using System.Collections.Generic;
using Sitecore.Diagnostics;
using Sitecore;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using Sitecore.Social.Api;

namespace SCcustom
{
    public class ReadPropertyFromMongo<T> : Sitecore.Forms.Core.Rules.ReadValue<T> where T : Sitecore.Forms.Core.Rules.ConditionalRuleContext
    {
        private string Network { get; set; }
        protected override object GetValue()
        {
          
            try
            {
                string networkname = "LinkedIn";
                networkname = Network;
                // Sitecore.Context.User.Profile.GetCustomProperty("soc_PrimaryNetwork") ;

                var socialProfile = new SocialProfileManager();
               
                // Do we have an extra profile from the user?
                if (socialProfile.SocialProfileExists(Sitecore.Context.User.Name, networkname))
                {
                    var soProfile = socialProfile.GetSocialProfile(Sitecore.Context.User.Name, networkname);
                    try
                    {
                        return soProfile.Fields[Name];
                    }
                    catch

                    { return ""; }
                }
                return "";
            }
            catch
            { return "network error"; }
        }

     
    }
}

Now we have to pass two parameters from Sitecore-"Name" and "Network" from Sitecore.

set-wffm-custom-action-sitecore-social-data


Custom rule will look for the "ln-headline" property in context user's Linkedin social profile. If any value is found it will return the value else it will return blank.

Below is the Output

wffm-populated-social-data-sitecore


Thursday, July 6, 2017

Sitecore Social Connected - Linkedin ( Sitecore 8+ )

Getting LinkedIn Profile data using Sitecore connected.


In this blog post i will be showing how to get the profile data from LinkedIn using Sitecore Connected. 

I will be covering below points-
  • Adding application in LinkedIn.
  • Setting up LinkedIn application.
  • Setting up Sitecore to use LinkedIn connection
  • Adding and configuring login with LinkedIn rendering.
  • Code snippet for getting profile data.

Adding application in LinkedIn  


for creating a new application in LinkedIn navigate to https://www.linkedin.com/developer/apps
and click on create  application . Fill in the required fields and click on submit.


Setting Up LinkedIn application


After adding the application open the application and set the Authorized Redirect URLs:


Copy Client ID and Client Secret .. Hit Update after adding url.

Setting up Sitecore to use LinkedIn connection


Login to Sitecore open content editor. Navigate to /sitecore/system/Social/Applications/Default.
right click on Default item and insert new application.



 Add the Application ID and Application secret copied from LinkedIn application.Select the network as LinkedIn.





Save the item.


Adding and configuring login with LinkedIn rendering.


Once configuration is done now you can add the login with LinkedIn rendering(/sitecore/layout/Renderings/Social MVC/Connector/Login with LinkedIn) to your page.





After adding the rendering you need to configure few Rendering parameters as shown below.




Click Ok. save and publish your page

You should be able to view the login button of LinkedIn on your page click on the login button it will redirect you to LinkedIn Authentication page. Enter the credential and click on allow access it should redirect back to the url which you provided earlier on rendering parameter.




It will add one query string parameter called authResult . If value is success means the login is successful else login failed.




Code snippet for getting profile data.

Now when login is successful the social profile data from LinkedIn gets attached to the Sitecore context user.
we can get those data by using below code and use it in our website.




below is the set of  data we can get -






we can configure the key data to be fetched from Sitecore.Social.ProfileMapping.LinkedIn.config file present at app_config/include/social folder.



Monday, April 4, 2016

Sitecore FXM- Issues and troubleshoots

Issues In FXM

  • Placeholder Setting depends only on html element structure, It should depend on page url as well.
  • Profile keys are not grouped by profiles in "Add Page Filter" section.
  • ­ Delay in response
  • Sitecore FXM does not support Sitecore Web Forms for Marketers (WFFM),Path Analyzer and Workflows


Quick troubleshoots­

403 forbidden

Error : ­ "There was an error saving the item ­ Forbidden"
Solution ­: Enable the Sitecore.Services.Client.FXM.Enabler.config.disabled config file located at /App_Config/Include/FXM.

CORS error 

 Error­ : The 'Access­Control­Allow­Origin' header contains multiple values 'http://, *', but only one is allowed."

 Solution : ­ Apply matching rule based on domain url.

Sitecore FXM Control panel

FXM Controls- Add Placeholder

  • Click on Add placeholder
  • Select any html element of external website.
  • Choose the proper place of placeholder(before/after/replace)
  • Give name of placeholder and select the parent node , Click Ok. Publish the website.

FXM Controls- Select Rendering/Sublayout

  • Once placeholder is added we can attach any sitecore rendering / Sublayout to that placeholder.
  • Click on placeholder, Click on "Add here"
  • Select the sublayout/rendering from dialog box.
  • Click select, Save and publish the website.



FXM Controls- Capture Click Action

Capture click action can be assigned to any button/link of the external website.

  • Click on Capture link action, select the button/link, Select “Add a new action”.
  • Add name and select the parent node. Save and Publish
  • By using Capture Click action we can trigger any Sitecore goal or Compaigns/Events.

FXM Controls- Add page filter

Add page filter is used to assign Sitecore action on the load of the page.

  • We can assign Profile card/Goals/Compaigns/Events to a page by page filter.
  • Select page filter, Give a name and select "Profile card/Goals/Compaigns/Events" which you want to trigger.
  • Save and Publish.

FXM Controls- Manage FXM functions

Manage FXM function displays all the FXM functions assigned to the site.

  • Click on manage FXM function
  • Select the listed fucntion which you want to update.
  • Update the function , Save and publish

Configuring FXM

Step 1

  • Login to sitecore go to launchpad and click on Federated Experience Manager

Step 2

  • Click on Add external website

Step 3

  • Enter external website address.
  • Copy the generated beacon script tags to the external website .
  • Click save

Step 4

  • Sitecore detects the script if it is found on external website.
  • Click on Publish
  • Click on open in experience editor
  • Your external website is ready to use FXM from sitecore.


<< What is FXM Sitecore FXM Control panel >>

Sitecore FXM

What is Sitecore FXM 


Sitecore Federated Experience Manager allows activity in non-Sitecore websites and applications to be tracked, and for content managed and personalized by Sitecore to be injected in non-Sitecore websites.
Imagine having access to Sitecore 8’s functionality, experience management, and analytical tracking abilities on any site, non­Sitecore sites included. Well, that is exactly what the Sitecore Federated Experience Manager (FXM) enables marketers and technologists to do.
FXM has existed in a number of different forms in past Sitecore versions. To no surprise, it has been known as the “CMS Anywhere Tool.” Well, with Sitecore 8, it is all that, and a lot more. FXM enables the management of not only content, but experience, personalization, and analytics in any platform. The installation of FXM on a site is as simple as adding a JavaScript code snippet to the target site – similar to installing Google Analytics. The application of FXM onto non­Sitecore sites will enable marketers to have a comprehensive picture of user behaviors and interactions across multiple websites. Those interactions can all be tracked and aggregated into one Sitecore instance; which can in turn leverage that information to present a much more meaningful user experience. That experience can also be remotely applied and specifically tailored – based on cross site user metrics – to fit the audience on any integrated site. In all, FXM allows marketers to unify the management of content, experience, and analytical tracking across an entire sphere of influence, into one consolidated Sitecore instance.
This new addition introduces the Sitecore DMS and its personalization capabilities to a whole new market by allowing users of Sitecore to take advantage of the Sitecore Experience Platform on non­Sitecore powered websites.

Key benefits:

  • Tracking Page Views of N-numbers of non-Sitecore sites.
  • Utilize Sitecore Analytics (Goals/Profiles/Campaign) for non-Sitecore sites.
  • Personalization of non-Sitecore sites.
Configuring FXM >>