Monday, 30 June 2014

How to bind sitecore field inline in repeater control?

Friends, How are you all doing?
I know you may have a question - "Long time, No Posts?" Yeah, I got some halt (e.g. busy with new project) in my sitecore journey. And in this halt - I have learnt many new things, now it's time to share these leanings.
So let's start knowledge sharing.

Scenario:
Have you come across a requirement where you are using asp.net control (e.g. repeater control) and you want to bind sitecore item field values inline without using any asp.net or sitecore control? If so, then this post may help you.

Many of you have rendered sitecore field value inline using below approach which is completely correct.
 
        
            
         
       
But, what if you want to bind sitecore field value without using any sitecore control (e.g. sc:fieldrender) or asp.net control?
In such case, you can use following approach:

        
            <%# ((Sitecore.Data.Items.Item)(Container.DataItem)).Fields["Text Heading"].Value %>
         
    
This is how you can render sitecore field inline:
<%# ((Sitecore.Data.Items.Item)(Container.DataItem)).Fields["Text Heading"].Value %>

Tuesday, 1 April 2014

A Beginner's Guide to Sitecore DMS - Part 2

In last post, we had seen how to set and trigger goal in DMS. If you remember - we have assigned BrochureDownload goal to ProductMannual PDF which got triggered whenever you click on PDF link.

So we have seen one way of triggering goal, fine? Actually there are three ways of triggering goal in Sitecore DMS. In this post, we are going to uncover remaining two ways to trigger goal.

Which are three ways to trigger goal in sitecore DMS?

  1. Tirgger goal on user action (covered in last post)
  2. Trigger goal using query string (will be covered in this post)
  3. Trigger goal programmatically (will be covered in this post)

Now let's see how to trigger goal using query string?

Sometimes you need to trigger goal without requiring user action. In such case you can take advantage of Sitecore query string variable sc_trk like this: http://plainsitecore7/?sc_trk=[goal name]

For Example: http://plainsitecore7/?sc_trk=BrochureDownload

The next thing in your mind may come - how can I check whether this query-string triggered your goal or not? You can check it at below section: How to check whether goal is triggered or not?

 

 Third way - how to trigger goal programmatically?

Before we proceed to see implementation of programmatically triggering goal, let's see in which scenario you would need this?

Suppose you want to trigger a goal on button click, and you cannot assign goal to button from Sitecore content editor. In such case, you can go with third option - trigger goal programmatically.

Scenario:
Your site has feature to subscribe for product newsletter, and you need to trigger goal whenever any user subscribed for this newsletter.


Implementation:
Sitecore.Analytics API provides built-in methods to trigger your goal. Here is code that you can hook into button_click event.
protected void btnSubscribe_Click(object sender, EventArgs e)
        {
            if (Sitecore.Analytics.Tracker.IsActive && Sitecore.Analytics.Tracker.CurrentPage != null)
            {
                Sitecore.Data.Items.Item GoaltoTrigger = Sitecore.Context.Database.GetItem("{1779CC42-EF7A-4C58-BF19-FA85D30755C9}");
                if (GoaltoTrigger != null)
                {
                    Sitecore.Analytics.Data.Items.PageEventItem registerthegoal = new Sitecore.Analytics.Data.Items.PageEventItem(GoaltoTrigger);
                    Sitecore.Analytics.Data.DataAccess.DataSets.VisitorDataSet.PageEventsRow eventData = Sitecore.Analytics.Tracker.CurrentPage.Register(registerthegoal);
                    eventData.Data = GoaltoTrigger["Newsletter subscription"];
                    Sitecore.Analytics.Tracker.Submit();
                }
            }           
        }
In above code snippet, Item ID-{1779CC42-EF7A-4C58-BF19-FA85D30755C9} is ID of your goal that you want to trigger on button click.


That's it!
Click on "Subscribe" button and it will trigger your "Newletter Signup" goal. The next question in your mind may come - how can I check whether goal is triggered or not?

How to check whether goal is triggered or not?

If you have this question in your mind, then at this time I hope you know answer of it also. Recall first post please, we have seen how to check report of "Goal and Events". If not able to recall, no problem - let's see report of this new goal - "Newsletter Signup"

Select the page on which you have added "Newletter Subscribe" button -> go to "Analyze" menu -> click on "Reports" -> select "Page - Goals and Events" report. You will see report having "Newsletter Signup" goal there.



Friends, hope that you are now clear with all three ways to create "Goals" in DMS.
Hope that this post series may help you in your DMS journey, will come with few more DMS points soon.

Want to decide marketing strategy of your site? Use Sitecore DMS!

Monday, 31 March 2014

A Beginner's Guide to Sitecore DMS - Part 1

Friends, recently got opportunity to explore Sitecore DMS and I found it very exciting. I have read about Sitecore DMS but never got chance to deep dive in, and that is what called your journey - Sitecore Journey.

Few of you may have situation like me, so to make you well prepared in advance - I am writing this post. The best part of this post is - it includes everything about Sitecore DMS at one place from installing to implementation and testing. Everything mentioned in this post can be found on web easily but on scattered posts.

For those who don't know definition of Sitecore DMS:
Nonlinear Digital has already briefed very well about What is Sitecore DMS? So I am not going to repeat introduction of DMS. You can read it at: A Marketer's Guide to the Sitecore DMS
Thanks to Nonlinear Digital!

Let's start your Sitecore DMS Journey now...

First of all, how can you check whether DMS is installed in your Sitecore instance or not?

If you are not sure whether Sitecore DMS is configured/setup in your local Sitecore instance or not and want to confirm it, then you can do it by visiting your ConnectionStrings.config file. If you find any entry of Sitecore_analytics database then it means that DMS is configured in your environment.

 

So from where can you find Sitecore DMS setup?

If you find Sitecore DMS is not configured in your local instance, then you need to visit SDN portal - http://sdn.sitecore.net/Resources.aspx and download respective Sitecore DMS version.

The downloaded ZIP file will contain Sitecore.Analytics.config file and Sitecore.Analytics database.

 

Now how to configure Sitecore DMS after downloading?

Step-1#:

First, you need to add connection string for Sitecore_analytics database in ConnectionStrings.config under App_Config folder and attach Sitecore_analytics database in your SQL Server.
<add name="analytics" connectionString="user id=[usename];password=[pwd];Data Source=(local);Database=Sitecore_analytics" />

Step-2#:

Copy downloaded Sitecore.Analytics.config file to your App_Config/Include folder.

How to confirm Sitecore DMS is working now?

You may be wondering how can you check whether you have configure Sitecore DMS successfully or not. You may want to check whether Sitecore DMS is working and recording any data or not.

In order to check it, visit/preview couple of pages of your Sitecore instance where you have configured DMS and then go to Sitecore Analytics database. Check Visits table under Sitecore Analytics database, you should found records of your visits there.


This means your Sitecore DMS is working, enjoy!

But how can you start using Sitecore DMS as you are noob?

So far, you have only configured Sitecore DMS and confirmed whether it is up and running in your local enviroment.

Now Let's use it to get real advantage of DMS - for which it is made.

There is dedicated menu option given for DMS under Sitecore menu - Marketing Center
To work with DMS, you need to go to Marketing Center. Here you will find many options like setting Goals, Campaigns, Engagement Plans, Personalization and many more.

So let's start with Goals, add a new goal as suggested below.


Hey, someone of you may have question - what is goal? why should you create goal? So let's see why are we going to create goal? 

Suppose that you want to track visits of all people who have downloaded ProductManual PDF from your website. This is called Goal in Sitecore DMS terminology, hence you need to create Goal under marketing center and assign it to respective PDF (ProductManual).

This process is also called as CAT in DMS:
Create goal
Assign goal
Track goal

Hope you are now comfortable with terminology - goal. So let's proceed further and create goal, I have created goal named - BrochureDownload.


Please note that you must have to deploy goal in order to assign it.



If you forget to deploy goal then you will not be able to see your goal in goal list as mentioned in below screen capture.You need to now assign this goal to ProductManual PDF, use below mentioned steps to assign the goal.


That's it - your ProductManual PDF has goal now. So let's link this PDF to your product page and rest of all things will be managed by Sitecore DMS.


It's time to track the goal now. Preview your page where you have linked ProductManual PDF and click on link to download it.



This will of-course download PDF and trigger the your BrochureDownload goal that you have set and assign to this PDF.

Again you may have question - how can you check whether my goal is triggered and achieved or not?
Yes, you have valid question. In order to confirm that, go to Analyze menu - select Reports option and then select Page-Goals and Events report type.


You can also check all such analytics report at Executive Insight Dashboard under Sitecore menu.
If you are not able to see Goal records in reports (as shown in above figure), please make sure that you have published that goal. Publishing goal will start showing data in Goals and Event report.


In case you are not able to view any visit data under Dashboard, that means you don't have enough visit data. To bypass this rule, you can change default sitecore configuration to pull whatever data you have. This can be achieved by changing MinimumVisitsFilter value from 50 to small value like 5 at: \Website\sitecore\shell\Applications\Reports\Dashboard\Configuration.config


So how did you like it? How was your first goal in Sitecore DMS?
There are many more things about Sitecore DMS in Part-2 post. Click here to read DMS Part-2 post.

How to get rowcount of all tables in SQL Server?

Recently while exploring Sitecore DMS feature, came across a situation where I wanted to know rowcount of all tables in Sitecore Analytics database. So like any other developer, I googled it and found many SQL Queries which accomplish this requirement. But I liked one query very much and hence wanted to share it via this post.

You simply need to copy and paste this query to your Query Editor in SQL Server, that's it.
DECLARE @QueryString NVARCHAR(MAX) ;

SELECT @QueryString = COALESCE(@QueryString + ' UNION ALL ','')

                      + 'SELECT '

                      + '''' + QUOTENAME(SCHEMA_NAME(sOBJ.schema_id))

                      + '.' + QUOTENAME(sOBJ.name) + '''' + ' AS [TableName]

                      , COUNT(*) AS [RowCount] FROM '

                      + QUOTENAME(SCHEMA_NAME(sOBJ.schema_id))

                      + '.' + QUOTENAME(sOBJ.name) + ' WITH (NOLOCK) '

FROM sys.objects AS sOBJ

WHERE

      sOBJ.type = 'U'

      AND sOBJ.is_ms_shipped = 0x0

ORDER BY SCHEMA_NAME(sOBJ.schema_id), sOBJ.name ;

EXEC sp_executesql @QueryString

The best part of this query is - it shows list of tables along with rowcount like this:


Thanks to www.mssqltips.com!
Source: http://www.mssqltips.com/sqlservertip/2537/sql-server-row-count-for-all-tables-in-a-database/

Friday, 28 February 2014

Is your Visual Studio 2013 not supporting SandCastle Help File Builder project?

Scenario:
Recently we have upgraded our project solution to Visual Studio 2013. Visual Studio 2013 is awesome, specially it's loading speed. VS 2013 is loading solution file very speedy compare to VS 2010. There are many other eye catching features in VS 2013. But I am not writing this post for it.. as you will find many blogs on VS 2013 features :).

Coming back to reason of this post - after upgrading our project to VS 2013, one of our project was not able to load. It was SandCastle Help File Builder project which was now no more supported with VS 2013. I was getting "unsupported project" error message.

Reason:
"SHFB Visual Studio Extension Package" of Sandcastle Help File Builder 1.9.7 is not supported in Visual Studio 2013. So you need to install "SHFBGuidedInstaller_1980".

How to load Sandcastle Help File Builder project in VS 2013?
I found that currently I have installed Sandcastle Help File Builder 1.9.7 on my system which supports VS 2010 very well. But it is not supporting VS 2013, you need to install Sandcastle Help File Builder 1.9.8 to support with VS 2013.

So if you are facing simillar situation like me, then go ahead and install version 1.9.8 from below link.

https://shfb.codeplex.com/releases/view/105809

Upgrade Visual Studio 2013, Install Sandcastle 1.9.8 !!!

Thursday, 27 February 2014

Are you facing PathTooLongException while syncing with TDS in Sitecore?

Scenario:
We were using TDS smoothly in our day-to-day development life, but one day suddenly it started giving exception while syncing with Sitecore. 

We were getting below exception:
"The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. (PathTooLongException):"
 

At first glance, we thought that it could be small and temporary issue with particular sitcore item and we can solve it easily.

But it was not like that, situation was gradually becoming critical and everyone of team was facing the same issue.

So we started digging into it and obviously first question in our mind was why did it stop suddenly? Why was it working smooth previously? Did we change anything in TDS configuration?

Answer was - No. We didn't change anything in Sitecore/TDS configuration. But yes, we did a small change and that was we moved our TDS project from short path folder to long path folder. 

Do you think this could create issue? No of course not..
We were also thinking like that, but friends it was the only reason which broke TDS sync.

Reason:
As message description implies, there is problem with long file path of TDS sitecore item. TDS cannot sync with sitecore if TDS physical item path exceeds 260 characters.

How to solve it?
As per Hedgehog Development, you need to set folder alias name property to fix it.


This solution is very well explained on Hedgehog Development offical site under title of "File System Aliasing with Team Development for Sitecore" (5th video) at below link.

http://www.hhogdev.com/products/team-development-for-sitecore/videos.aspx

We became happy after seeing this solution and jumped to apply it. But unfortunately it didn't work with our environment, reason could be our TDS project is bound with SVN source-safe. We were getting "Invalid Value" message after following solution steps mentioned in above video. I am not sure why that solution was not working, we tried on few systems and everyone was facing same message.

Finally the only solution that worked was - "shorten TDS project folder path".
We moved our TDS project to near C:\ drive and it's done. But I would advise you that you should first go for "folder alias name property" and if it does not work for you like me then only go for "shorten folder path" option.

And yes, I reported this issue to Hedgehog Development support team. They replied quickly with the same solution mentioned in above video (e.g. set folder alias name property)

Friends, isn't it interesting story :)?

Facing Sitecore TDS sync issue, set folder name property/shorten TDS project path!!!


Thursday, 6 February 2014

Should you use package OR serialization in sitecore?

Scenario:
Few days ago, our deployment team sent us instructions to update our sitecore instance. I found that they have sent sitecore serialization items to update sitecore instance, I started to update my local sitecore instance using sitecore serialization items. But there was a question roaming in my mind, why they have provided serialization items and not package? What is difference between package and serialization (package Vs serialization) in sitecore?

Reason:
The reason why such question arise in my mind was - I always use sitecore package to update/deploy items. Although I was aware that serialization can be used to update/deploy sitecore items. All these thoughts made me to find which is good option to deploy sitecore items - package or serialization?
 
How to decide which option to use?
Here are my findings which shows difference between sitecore package and serialization.

1) Sitecore Package:
  •  There is size limit of 2 GB for package creation in sitecore, so you need to create multiple packages instead of creating one package if your deployment exceeds 2 GB size.
  •  After installing package, if you have changed few items and now you want to revert these items back to original version then there is no way to achieve it.
  •  For example: If your package contains 50 new items, then you will have 50 new items in your sitecore instance after installing this package. Now let say you have changed 10 of these 50 items and you want to revert these 10 items back to previous version (same version when you installed package), then there is no such mechanism in package installation which will help you to revert these specific 10 items. 

2) Sitecore Serialization:
  • There is no size limit of serialization items in sitecore.
  • You have option to revert your installation using revert options (e.g. revert tree, revert items) in serialization.






 

So it's better to use "Serialization" than "Package" - lesson I learnt.

Note: Always use firefox browser while installing items from "package" or "serialization" because Internet Explorer gets time-out issue while installing a big package. If you want to know details about this, then do visit my colleague's blog.

Big sitecore deployment? use serialization !!!