Wednesday, 15 June 2016

How To Convince Your Client For Sitecore 8+ Upgrade?

Are you Sitecore developer?
Hearing a lot about Sitecore 8 but still working on older version like 7?
Do you want to upgrade your project on Sitecore 8 but don't know how to convince your client?

Being a developer you will always like to work on latest version of Sitecore but we are struggling to showcase business benefit to client why we should move to latest version.

If you are surrounded with above questions, then convince your client by demonstrating below business benefits that you will get after upgrade to Sitecore 8+.

Disclaimer:
Before you start reading this post, I would like to mention that the content of this post is borrowed from Internet and idea behind writing this post is to list down all Sitecore 8.0 eye catching features at one place. This post is one stop solution that will help you to win Sitecore 8 upgrade project. Thanks to Sitecore community for posting all these features.



Why Sitecore Customer Experience Platform 8?

As a leader in the world of customer experience management, new and exciting updates to Sitecore’s features and functionality are always hotly anticipated. None more so than Sitecore 8, which sees the platform step up its capabilities even further than before.

This compiled document will explore some of the most important and exciting features that have been introduced from Sitecore 8 onwards.

A whole new user friendly look

The Sitecore® Experience Platform™ 8.1 CMS has a completely new user interface compared with earlier Sitecore.


The look and feel of the client is much improved. After the initial load, performance feels much quicker than Sitecore 7.5 and previous versions. The Launch Pad icon at the top of the page comes in very handy when wanting to switch between the new Sitecore 8 components and content editing, or experience editing; features that you’re already used to using in pre-8 installations.


Moving through the various steps of editing content, publishing, workflow, etc. match that of previous versions — just in a different layout. Everything is pretty much where you would expect it, but with a cleaner look and feel.











Continuous testing and optimization

With Sitecore XP 8.1, everything can be optimized easily—test an entire page, a component, or specific personalization element. All changes can be automatically A/B tested, by any content creator, and Sitecore’s analytics will attempt to find additional optimizations automatically. Advanced optimization experts also have all the tools they need to set up sophisticated test scenarios, like multi-variate tests, built into the platform. So every component and every channel can be fine-tuned for performance, continuously.













Workflow

When moving content changes through Workflow, new “Approve with Test” and “Approve without Test” are available, consistently reminding content editors and decision makers to consider A/B testing at a content level.






Email Experience Manager

The layout of the email campaign manager has changed, allowing for message creation and list importing available from the same menu









Know Your Customers Better - Experience Analytics

New to Sitecore 8, the Experience Analytics feature brings together multivariate testing results, engagement scoring and overall site tracking statistics together in one location. The result is a powerful, new array of reports coupled with date range filtering and reporting facets.











Path Analyzer

One of the new features I’ve had the most fun with so far is the Path Analyzer. Clicking on the map, zooming in and out, selecting successful and least effective paths is really quite fun. The example below is leveraging Analytics data collected from a Launch Sitecore instance:





Selecting a path by clicking on the map, leading from a mail campaign to a login page yields the results below. Clicking on an element within the funnel of a selected path visit shows the exit path from that particular page:





You can also select a path from the lists in the right navigation, narrowing down on a particular path of high importance. For instance, the selected path below is one of the most efficient full paths:





Showing the funnels of the select path:






Fully integrated Device Detection features

The Sitecore Device Detection service uses a visitors’ browser user agent string to identify that visitors’ device and extract the device properties (such as device model, browser, device operating system, screen size, HTML5 audio and video capabilities). The service supports the Experience Database (xDB) and Experience Analytics, allowing content authors to pull reports based on visitors’ device and device usage, then enabling them to optimize and personalize these visitors’ website experiences – specific to their device and its properties. For example, an optimized visitor experience could include a mobile-friendly layout (through adaptive or responsive web design) as well as a personalized experience through promotions designed for a visitor using an Apple iPhone.

**The Sitecore IP Geolocation service will be available via a subscription in the Sitecore App Center.


Fully integrated IP Geolocation features

The Sitecore IP Geolocation service uses website visitors’ unique IP addresses to automatically populate the Sitecore xDB with location details, for example, country, region and city, when they visit a Sitecore-powered website. Depending on the IP address, company information is also sometimes available. This information helps personalize customers’ experiences and optimize their campaigns through segmentation, personalization and profiling strategies.

**The Sitecore IP Geolocation service will be available via a subscription in the Sitecore App Center.


Social

Social is delivered out of the box with Sitecore 8. Previously, this required a separate installation of the Socially Connected module from SDN.

Available from the Page Editor, the “Messages” button under “Social” allowing content editors to create, edit and post a message on a target network. Take note of the new “Social” node in the content tree directly under the Sitecore root node.




One view of your customer

The Sitecore® Experience Profile™ provides a single view of each individual customer, used for real-time personalization, segmentation, and analytics. Sitecore collects and connects data about the whole customer experience, wherever it happens, making it immediately available to marketers to continue ongoing conversations and provide highly relevant and contextualized experiences for their customers.



Integrated content and commerce

Sitecore XP 8.1’s Sitecore Commerce add-on integrates content and commerce, so your customers’ online shopping journey is seamless and, because it uses all the data in the Experience Platform, you can personalize offers throughout that journey. However, Sitecore can also integrate with your existing Commerce software to deliver similar capability, helping you improve the ROI on your existing technology investments.


Federated Experience Manager (FXM)

This adds the power of Sitecore to non-Sitecore sites.

There are two benefits: Firstly, it adds content syndication, personalization, MVT testing to external sites, and secondly, it adds tracking facilities and insight from these back into DMS from these external, non-Sitecore sites thus enriching the data insight and personalization.



What If You Don’t Upgrade?

Sometimes, upgrading isn’t necessary and choosing to stay-the-course is the most intelligent move. There are, however, some points to consider before making a decision.

Infrastructure – Sitecore is an ASP.NET application and thus relies on the entire Windows family of services to run. If the fundamental components of a Sitecore version are outdated, the entire system can become unreliable. For example, if a security exploit is found in SQL server that is patched in later releases, it may cost a company more for not upgrading than it would have to simply upgrade originally.

Bugs – Each new version of Sitecore fixes bugs from previous versions. While many go unnoticed, they could be affecting the user experience or site performance.

Sitecore Support – Like any product, Sitecore will eventually drop support of older versions. A support lifetime matrix is available to view when support for each version ends.

Marketing – Ultimately, a corporate website is a marketing tool. By not upgrading, your site objectives – lead generation, nurturing, thought leadership and recruiting – could take a hit.


Thanks to all Sitecore community members to help me to create this consolidated feature list!

Wednesday, 8 June 2016

Live Streaming And Tracking Tweets in .NET

When you google "live streaming tweets" or "real time tweet tracking", you will find loads of APIs those will help you to achieve your task.

Now you will be thinking then why I am writing this post?

Well, there are main two reasons behind it.

1) Since you will find that there are many APIs available in market, which API should you use? How to get started? This blog post will help you on this by putting all things together. It will cover everything from soups to nuts to track live tweets.

2) Most importantly, how to real time track twitter emoji? To cover this point, it's prerequisite to understand first point (e.g how to track tweets real time). We will discuss this second point in my upcoming blog post.

So let's first see how to track tweets real time. Tweetinvi is the best API/Library I have found which has wide range of features to track tweets. As all the features and events of Tweetinvi is very well documented, I am not going to discuss it and rather I will focus on how to get started using it.

1) How to Get Started?


Here is the step by step process to get started with Tweetinvi.

Step-1: Install Tweetinvi NuGet

Tweetinvi is an intuitive .NET C# library to access the Twitter REST API. To install Tweetinvi, run the following command in the Package Manager Console

PM> Install-Package TweetinviAPI




Step-2: Write a code to connect with Twitter



Step-3: Write a code to track tweets based on keyword real-time



You can track tweets based on many criteria such as Geo-Location, Followers and many more. Refer Tweetinvi's official documentation on GitHub for the same.

For example: Write a code to track tweets based on Geo-Location real-time
Below code tracks all live tweets happening at Dubai.




Here is the complete code
 
static void Main(string[] args)
        {
            Auth.SetUserCredentials("key1", "key2", "key4", "key5");
                       
            using (var webClient = new WebClient())
            {
                webClient.Proxy = WebRequest.DefaultWebProxy;
                webClient.Credentials = System.Net.CredentialCache.DefaultCredentials; ;
                webClient.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
                webClient.Headers["User-Agent"] = "MOZILLA/5.0 (WINDOWS NT 6.1; WOW64) APPLEWEBKIT/537.1 (KHTML, LIKE GECKO) CHROME/21.0.1180.75 SAFARI/537.1";

                var creds = new TwitterCredentials("key1", "key2", "key3", "key4");


                var stream = Stream.CreateFilteredStream();                                
                
                stream.AddTrack("Technology");
                stream.MatchingTweetReceived += (sender, a) =>
                {
                    Console.WriteLine(a.Tweet.Text);
                    Console.WriteLine(Environment.NewLine);
                };

                var StreamThread = new Thread(() => stream.StartStreamMatchingAnyCondition());
                StreamThread.Start();
            }
        }

Step-4: See the result!

Running above code snippet will start live streaming of tweets having keyword "Technology" shown in below screen.


This was the just half journey completed for me.
Remember point-2?  How to real time track twitter emoji?

I still need to find a way to track tweets based on emoji icons. Neither Tweetinvi API nor Twitter API provides a direct way to track twitter emoji. This was a challenge for me and finally I was able to crack it. We will see how to track twitter emoji real time in upcoming post.


2) How to real time track twitter emoji

Check it out at Part-2 blog post.


Tuesday, 17 May 2016

Hidden Power Of Sitecore Dictionary Item

Scenario:

Till the time your Sitecore website is in single language, everything will work smooth. But the moment you are asked to add one more language in existing solution, I am sure you will come across below situation.

You have 90% of content coming through Sitecore which means 90% of your website is content managed.

You have 10% of content is hard coded which contains button text, place holder text etc.. as illustrated in below screens. This will make you worry if you want to add one more language in site and make them content managed.





If you are facing similar situation, then you are at right place.. carry on...

Solution:


Option-1

At first glance, you will jump and start thinking to add fields for all those hard coded value in     respective Sitecore item templates. This solution will fit if those hard coded values are page specific. But think for a while why those values are hard coded? The obvious reason is nature of content. This content might be any of below types:
  • Button text
  • Placeholder text
  • Message text
  • Tooltip text and so on..

Hmm.. now you got the reason why those values are hard coded. You must be thinking now:
  • What to do now? 
  • How to make these hard coded values content manageable? 
  • Where to add them in Sitecore as they are NOT related to particular page template?
  • This content are common and used across the site. 
    • For example: "Find" button is used on many pages of the website.

Option-2 will answer all of your above questions.


Option-2

There is one hidden hero in Sitecore which we rarely use and can save our life in this scenario.
It is Dictionary Item.

1) You can now create dictionary items under /sitecore/system/Dictionary/ for all of above hard coded button, placeholder and message content.



2) Add below piece of code to render content from Dictionary Item based on key.

public static class Helper
{
   public static string GetDictionaryItem(string key)
   {
          if (string.IsNullOrEmpty(key))
              return string.Empty;

            string dictionaryValue = string.Empty;
            dictionaryValue = Translate.Text(key);
            return dictionaryValue;
   }
}

Before:
<button type="button" id="btnFind">Find</button>

After:
<button type="button" id="btnFind">@Helper.GetDictionaryItem("Find Button")</button>


Result:

Above code will now pull content from respective Sitecore dictionary item as shown below.



Advantages of using Sitecore Dictionary Item:
1) You don't need to touch existing templates to add new fields
2) You can use same dictionary content across the site. For example, there are ten places where you have hard coded "Find" button text. You can use same dictionary item at all those ten places.
3) Like other Sitecore item, you can add different language versions of Dictionary items.

Hope you will now take the advantage of Sitecore Dictionary in such scenario.
Keep your Sitecore Journey going on!

Thursday, 21 April 2016

How to Upload Your Media To Amazon S3 Programmatically?

One of the best tricks to improve performance of your website is to reduce the server load.

So how can you reduce server processing time?
If you observe closely, most of your page load time is getting consumed by images and videos of that page. Instead of keeping all resources on one server, you can put some resources such as heavy images and videos on other server. This other server will be treated as CDN server and this technique is called CDN.

This post has everything from soup to nuts about uploading media files such as video or image on Amazon S3.

What is Amazon S3?
Amazon Simple Storage Service is storage for the Internet. It is designed to make web-scale computing easier for developers.

Amazon S3 has a simple web services interface that you can use to store and retrieve any amount of data, at any time, from anywhere on the web. It gives any developer access to the same highly scalable, reliable, fast, inexpensive data storage infrastructure that Amazon uses to run its own global network of web sites. The service aims to maximize benefits of scale and to pass those benefits on to developers.

I borrowed above definition from Amazon's official website. If you are looking for more details about it, then you can refer this link.

Enough theory, let's start some practicals...

Step-1: Installation

Install AWSSDK NuGet package from Visual Studio.



Step-2: Code Snippet

Once you install AWSSDK, you can now use Amazon S3 APIs to upload images or videos to the Amazon server. But for that you will need below three things.
  1. Amazon S3 Bucket URL
  2. Amazon S3 Access Key
  3. Amazon S3 Secret Key
In my case, I have created a dashboard screen from where user can upload any video to Amazon S3.


Here is the code to upload selected video to Amazon S3 bucket.
 protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (videoFile.HasFile)
                {
                    IAmazonS3 client;
                    AmazonS3Config a = new AmazonS3Config();
                    
                    using (client = AWSClientFactory.CreateAmazonS3Client(ConfigurationManager.AppSettings["AWSAccessKey"],
                           ConfigurationManager.AppSettings["AWSSecretKey"], RegionEndpoint.APSoutheast1))
                    {
                        if (ConfigurationManager.AppSettings["AmazonS3BucketName"] != null && 
                            ConfigurationManager.AppSettings["AmazonS3BucketURL"] != null)
                        {
                            string bucketName = ConfigurationManager.AppSettings["AmazonS3BucketName"];
                            string AmazonS3BucketURL = ConfigurationManager.AppSettings["AmazonS3BucketURL"];
                            PutObjectRequest request = new PutObjectRequest();
                            request.BucketName = bucketName;
                            request.CannedACL = S3CannedACL.PublicRead;
                            request.Key = videoFile.FileName;
                            request.InputStream = videoFile.PostedFile.InputStream;
                            PutObjectResponse response = client.PutObject(request);

                            Video objVideo = new Video();
                            objVideo.Title = txtTitle.Text;
                            objVideo.Description = txtDesc.Text;
                            objVideo.Url = AmazonS3BucketURL + videoFile.FileName;
                            objVideo.CategoryId = Int32.Parse(lstCat.SelectedItem.Value);
                            objVideo.IsActive = chkIsActive.Checked;
                            objVideo.Language = lstLang.SelectedItem.Value;
                            PepsiBeINUclBAL objBAL = new PepsiBeINUclBAL();
                            int i = objBAL.InsertVideoDashBoard(objVideo);
                            if (i >= 1)
                            {
                                lblMsg.Text = "Video added sucessfully";
                            }
                            else
                            {
                                lblMsg.Text = "Oops.. some error occured while submitting video.";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lblMsg.Text = "Oops.. some error occured while submitting video.";
            }
        }


You will get "status" property of  PutObjectResponse as OK if your media gets uploaded successfully on Amazon S3 bucket.

Step-3: AWS Key Configuration

Define all required Amazon S3 keys and URLs in web.config file, so that you can change them later on if you want.



Step-4: Amazon S3 File Browser

Finally you will be thinking how to confirm that media is successfully uploaded on Amazon S3 bucket and looking for URL of the same.

It's simple. Amazon S3 URL for the uploaded media will be like this:
AmazonS3BucketURL + "/" +  [Uploaded Media File Name]

For exanple:
https://youramazonaccountprefix.s3.amazonaws.com/video1.mp4

If you are looking for a way to browse all media files uploaded so far on your Amazon S3 bucket, then Amazon S3 Browser can help you on that. You can download Amazon S3 Browser from here


That's it!
Hope this article will give you everything to get start with Amazon S3 upload.

Wednesday, 20 April 2016

Show Animated Notification Message While Postback

Many times while inserting or deleting records, you want to show a friendly notification message to user about that action.

Unlike desktop application, you don't have facility to show such message out of the box in web. Also showing java-script alert message is out of the fashion now.

Now there is trend of BootStrap and Notify JS for such stuff. So let's see how to show animated message to user about the action performed.

Step 1:
Include JQuery and Notify.JS in your page.

<script type="text/javascript" src="/admin/common/script/jquery-min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/notify/0.4.2/notify.min.js" type="text/javascript"></script>


Step 2:

Define variable to hold the value of different actions performed by user which you will use later on to show notification message accordingly.



Now set the operation variable as per the action (e.g. "Save" or "Delete) as shown below.



Finally based on the variable you set, show notification message to user by using $.notify() function.


Whenever user will save record, below message will appear and then disappear after few seconds.



This is simple but impressive way of showing notification to user about the action performed! Isn't it?

Wednesday, 9 March 2016

Are you getting "Error converting data type nvarchar to datetime"?

Mates - you must be thinking that why such a long halt in my Sitecore Journey? Well, I got a chance to explore new world, new people and new land of Sitecore. My responsibilities are now increased and I am working on many technologies along with my passion - Sitecore. Seems exciting? Yes, it is.

Being a Sitecore programmer, you will rarely touch SQL Server. But sometimes you need to introduce external database in your Sitecore application in order to meet business requirement. Today I am going to share one simple but life saving tip of using SQL Parameters in your code.

Most of us heard that saying "Everything works on developer's machine" :) But the moment code deployed to client's server, you face many surprises.

One of such surprise is culture difference between your sever and client's server - technically speaking "Language and DateTime Settings" difference. I have faced similar situation where my code was working fine on local server and not on client's machine. It was showing me below error.


Below code was working fine on my local machine and not working on client's machine. After troubleshooting I found below highlighted line was culprit.


Then I found that it's always best practice to pass datatype in SQL Parameters when you are dealing with of "DateTime" field.

So I rewrote above highlighted line as shown below and it fixed the issue.
    SqlParameter paramGMDate = new SqlParameter("@MatchDate", SqlDbType.DateTime);

    paramGMDate.Value = matchStatsObject.GameDate;

    cmd.Parameters.Add(paramGMDate);


That's it. If you follow this tip then it will save your life and will not face any surprises after shifting your code to different environment.

Thanks for reading, stay tuned for more such tips and tricks!!!


Tuesday, 26 January 2016

Is Your Sitecore Query Not Working?

Friends, hope you are enjoying your Sitecore Journey! Let's start our today's journey.

Scenario:
What do you do when you find that your Sitecore query is NOT retuning any result even-though query is correct? The obvisous answer is you will go to Sitecore CE and fire that query using developer center, right? Yes - this is perfect troubleshooting step.

I did the same, but was not able to understand that why Sitecore was giving error while executing that Sitecore query. I found no issue in syntax, then I tried same syntax by changing item name in query and it worked!

This gave me some clue. It was now clear that there must be something with that particular item name and that made to write this post to help my Sitecore Journey riders!

 Reason:
 If your Sitecore query contains any reserve words (keywords) then it will throw an error. In my case, item name was containing word "and" which is Sitecore keyword.



Solution:
Now you will find this post very simple because being a developer you know that every language gives some way to handle these escape characters (keywords). So you need to handle these escape characters in order to fix this issue.

I took advantage of .NET extension method feature and created extension method which will take Sitecore item as input parameter and will return formatted item path after handling these Sitecore keywords.

 public static string GetFormattedItemPath(this Item itm)
        {
            string itemPath = itm.Paths.FullPath.ToLower();
            if (itemPath.Contains(" and "))
            {
                itemPath = itemPath.Replace(" and ", " #and# ");
            }
            else if (itemPath.Contains(" or "))
            {
                itemPath = itemPath.Replace(" or ", " #or# ");
            }
            return itemPath;
        }

Above code handles only two keywords, but you can customize this code to handle entire list of Sitecore keywords as per your requirement.

After writing above extension method, you simply need to call this method using your item object.
For example:
Item currentItem = Sitecore.Context.Item;
repeaterControl.DataSource = Sitecore.Context.Database.SelectItems(currentItem.GetFormattedItemPath() + "/Comments//*[@@templatename!='Folder']")

Below is a list of words that needs to be escaped when used in Sitecore query:
  •    and
  •    or
  •    child
  •    descendant
  •    div
  •    false
  •    following
  •    mod
  •    parent
  •    preceding
  •    self
  •    ancestor
  •    true
  •    xor

Have a Happy Sitecore Journey!