Sitecore: Adding languages for a multilingual site

This is the first in a series of blog posts covering everything you should need to know for building a multilingual site in Sitecore.

The first requirement for a multilingual site is for the content editors to be able to enter content in different languages.

Language Selector

In the top right corner of the content editor on any item, is the language drop down that content editors will use to switch between the language version they are editing. However by default it will only show English : English

Configure the language options

To configure the language options on the drop down:

  1. In the content editor go to System > Languages
  2. Right click the language node and choose Insert Language
  3. A predefined language code drop down lets you pick between a set of predefined languages
    Insert Language
  4. Click Next, Next, Next until the dialog window closes. The language will be added to the language list and your content editors can start adding there content
    Language Selector with Poland
  5. Starting with Sitecore 8, languages are no longer automatically assigned a corresponding flag as there icon as it is no longer used in the language selector. If you wish to add an icon however you can still do this in the normal way by going to the configure tab, clicking the icon drop down and selecting More Icons. The flags are all still in an icon group called flags.
Advertisements

Sitecore: Setting up Mongo with Authentication

One of the new features in Sitecore 7.5 was the xDB, a new analytics database that rather than using SQL Server was Mongo based. If your main job is as a Sitecore dev, like me this may be the first time you’ve ever had to use Mongo, or a least the first time you’ve ever had to commercially use it.

Installing Mongo DB is a relatively painless experience, Mongo provide a decent enough guide to installing on Windows. Half way through you may be wondering why its running in a console window, but eventually you get to instructions for setting it up as a service.

However there are a couple of gotchas:

  1. Sitecore doesn’t work with the latest version of Mongo. At time of writing the latest version of Sitecore is 8.0 rev. 150427 and Mongo is 3.0. Sitecore however only supports version 2.6.x of Mongo though.
  2. None of the installation instructions include any details on authentication. Which while this is fine for your local dev machine is not so great for a live site.

So here’s my guide for getting up and running with Mongo DB and Sitecore.

Installing Mongo

First off get Mongo DB installed as a service on your machine. I’m not going to include instructions here for this bit, just follow the guide on the Mongo DB website.

One thing to note though, the Windows installer for Mongo 2.6 will by default install Mongo to C:\Program Files\MongoDB 2.6 Standard\. However the instructions for setting up Mongo include example commands expecting it to be installed in C:\mongodb\

Setting Up Authentication

Once you’ve got Mongo up and running you’ll need to create a user.

  1. Open a command prompt and connect to MongoDB
    C:\Program Files\MongoDB 2.6 Standard\bin\mongo.exe
    
  2. Switch to the admin db by doing
    use admin
    
  3. Create the user using
    db.createUser({user: "admin_mongo",pwd: "your password",roles: [ { role: "userAdminAnyDatabase", db:"admin" }, { role: "root", db:"admin" } ]  })
    
  4. To verify the user has been created you can use the following commands
    db.auth("admin_mongo", "your password")
    db.getUsers()
    

Mongo Create Admin User

Next update your config file to require authentication by adding auth=true. You will also need to restart the service for the change to take effect.

logpath=c:\data\log\mongod.log
dbpath=c:\data\db
auth=true

Sitecore uses 4 db’s in Mongo; Analytics, tracking_live, tracking_history and tracking_contact. We need to create a user in each of them.

Open a mongo shell again, switch to the admin db and connect with your admin login.

Now create each of the users as follows:

use analytics
db.createUser({user: "mongo_user",pwd: "your password",roles: [ { role: "readWrite", db:"analytics" } ]  })
 
use tracking_live
db.createUser({user: "mongo_user",pwd: "your password",roles: [ { role: "readWrite", db:"tracking_live" } ]  })
 
use tracking_history
db.createUser({user: "mongo_user",pwd: "your password",roles: [ { role: "readWrite", db:"tracking_history" } ]  })
 
use tracking_contact
db.createUser({user: "mongo_user",pwd: "your password",roles: [ { role: "readWrite", db:"tracking_contact" } ]  })

Sitecore Connection Strings

All that’s left now is to update the connection strings in Sitecore.

The default connection strings Sitecore give you look like this:

  <add name="analytics" connectionString="mongodb://localhost/analytics"/>
  <add name="tracking.live" connectionString="mongodb://localhost/tracking_live"/>
  <add name="tracking.history" connectionString="mongodb://localhost/tracking_history"/>
  <add name="tracking.contact" connectionString="mongodb://localhost/tracking_contact"/>

The format for a connection string with authentication is

mongodb://[username:password@]host1[:port1]/database

Your connection string should now look something like

  <add name="analytics" connectionString="mongodb://mongo_user:your password@localhost/analytics"/>
  <add name="tracking.live" connectionString="mongodb://mongo_user:your password@localhost/tracking_live"/>
  <add name="tracking.history" connectionString="mongodb://mongo_user:your password@localhost/tracking_history"/>
  <add name="tracking.contact" connectionString="mongodb://mongo_user:your password@localhost/tracking_contact"/>

Sitecore: How to change the personalisation trigger page count

One of Sitecores features is the ability to assign profile cards or profile key scores to pages. As visitors browse the website the profile key scores from each page are added to the visitors profile. Visitors are then assigned a pattern card using N-Dimonsional Euclidean Distance to calculate the closest matching pattern card to the visitors profile.

However before a pattern card is assigned to a visitor they must visit a minimum number of pages. The default for this is set to 3.

Reasons for changing this could be that you actually want to be more certain of a users profile before triggering personalisation this could be to avoid visitors landing pages on the site heavily dictating which persona they initially become profiled as, which in turn could influence personalisation that keeps them in that persona.

Or it could be because you want to lower the number of pages for a more immediate effect.

Whatever the reason to change the default from 3 you need to add the following setting to your config:

 <setting name="Analytics.Patterns.MinimalProfileScoreCount" value="3"/>

Increasing the Maximum file size for Web.Config

Web-Config-Exceeds-Max-File-Size

This can happen in any ASP.NET Web Application, but as Sitecore 8’s default web.config file is now 246 kb this makes it extremely susceptible to exceeding the default 250 kb limit.

To change the size limit you need to modify/create the following registry keys:

HKLM\SOFTWARE\Microsoft\InetStp\Configuration\MaxWebConfigFileSizeInKB  (REG_DWORD)

On 64-bit machines you may also have to update the following as well

HKLM\SOFTWARE\Wow6432Node\Microsoft\InetStp\Configuration\MaxWebConfigFileSizeInKB (REG_DWORD)

You will probably find that these keys need to be created, rather than just being updated. After changing them you will also need to reset IIS.

Alternatively

Alternatively you can leave the default values at 250 kb and split the web.config files into separate files.

More information on doing this can be found here:

http://www.davidturvey.com/blog/index.php/2009/10/how-to-split-the-web-config-into-mutliple-files/

My personal preference for Sitecore projects is to update the the max file size as this allows keeping the web.config file as close to the default install as possible. The benefit of doing this is it makes upgrades easier, rather than needing to know why your web.config doesn’t match the installation instructions.

Splitting a design into components for Sitecore

An important step when converting a design into a Sitecore site, is to correctly split the design up into components. Care needs to be taken to ensure sections that could be reused on different pages are correctly separated, and decisions made between what sections of a page should get there data from the context item and which will be linked to a separate datasource.

If your new to Sitecore, the video below from the Master Sitecore YouTube channel gives a great introduction on how to split up a design.

Extending personalisation options using the SBOS Accelerator

SBOS Rules Editor

A few weeks ago I blogged about extending profile matching over multiple visits in Sitecore. The basis of the post was to look at options on how you could extend Sitecore so that personalisation could use historical persona data rather than just data from the current session.

In this post I’m going to be looking at the SBOS Accelerators module which lists as one of its features “Historical Conditional Renderings”.

So what does it do?

Rather than change the way data gets recorded about a user, the SBOS Accelerator adds an additional 5 personalization rules to the rule set editor. These are:

  • where the specific campaign has been triggered within x days
  • where the specific goal has been triggered within x days
  • where behavior based on last x days matches the specific pattern card in the specific profile
  • where the specific page has been visited within x days
  • where the value of specific profile key compares to specific value, based on behavior from last x days

As well as allowing a rule to look at profile data over a number of days, the days option can also be changed to look at profile data over a number of visits.

This option of allowing us to specify a number of days or a number of visits helps to overcome the issue of data needing to degrade at different rates over time. We can set rules to promote something that a user may still be interested in by limiting the data to the last week, or we can target personality traits that shouldn’t change by taking a few months into consideration.

What’s important to note though is profile data is still being recorded on a per visit basis, so we still don’t have an overall accumulation of points over time and an assigned pattern card is still being based on an individual visit. But we’re able to create rules based on pattern cards assigned in multiple visits.

Some things to note

The SBOS Accelerators are currently only available for Sitecore versions 6.6 – 7.2. It currently hasn’t been updated to work with the new Mongo based analytic’s db in 7.5+.

The module has been written by Sitecore Support and is marked as being tested by Sitecore, so you can expect a decent level of reliability. However it is not covered by your Support agreement with Sitecore so you may not get any help with issues you encounter. The source for the module is available for you to edit though.

Links

SBOS Accelerators on the Sitecore Marketplace