Saving Data To Sitecore Analytics From Custom Code - sitecore

I have been using Sitecore for a couple of years, and now looking to begin utilizing the Experience functionality found in Sitecore 8.
I have a view that will capture some user-provided data. How do I go about creating a "person" (don't know the correct Sitecore terminology) in the Analytics database from custom code.

You'll need to create a Contact. Contacts are a kind of profile store for xDb and allows you to store data about your visitors. A contact has a built in list of facets (email, phone number, name etc) that make up the contact record, but it's also possible to create your own facets.
If you are building a form to capture data you can use the new Tracker api to identify and update facets on a contact.
Here's some code to do this:
https://github.com/ianjohngraham/CoreBlimey.Utils/blob/master/CoreBlimey.Utils/xDB%20Contact%20Creator/CreateContact.aspx.cs
There's a walk through of how the code fits together here:
https://m.youtube.com/watch?v=Jq6TpMgUGAk
(Apologies for the sound quality)
Also if you are using the WFFM module in Sitecore 8 there are some new save actions that will create contacts and store xDB data.

You may want to spend time on the docs. Please refer here for articles and guides related to Personalization and Personas.
Most of the configuration can be specified in Experience Analytics within Sitecore and you can leverage Rules Engine to perform actions.

Related

Custom filtering on default Experience Analytics Dashboard reports

So I am looking into extending a little bit the Sitecore reporting in the Experience Analytics Dashboard by adding an additional (custom) filter.
So the filters are:
Date Range Filter (pre-existing)
Subsite Filter (pre-existing)
Store Filter (NEW)
Please notice that I am not doing a static report - I would like EXISTING reports to take into consideration my NEW custom filter.
I have used the ideas introduced in the post by Mohammed Syam in order to provide the frontend part of the new filter (and it is there, with combobox coming up, URL adding an additional query string parameter). I am just not sure where would I go to tweak the "receiving end" for existing reports.

Sitecore DMS + OOB ways to track social share

Is there any OOB way to track the Social Share thru Fb, LinkedIn and Twitter.
We are not using the default social share rendering provided by Sitecore. These are normal links with JS code to share on fb,twitter etc..
Please guide.
An ootb way is not available but it can be done rather easily with some custom code. I wrote a blog post about integrating the AddThis component with xDB a while ago.
It's a combination of some javascript (you'll need to adapt this to your social share solution, but it's actually nothing more than making a call when sharing) and a controller. The controller will trigger the actual goal (or event...) you want. The blog has code for Sitecore 8.1 - this might differ for other versions (don't know your version). In a 8 environment, you need this:
We try to find the goal (Sitecore item) based on the post parameter.
If found, we use that data to register a PageEvent to the PreviousPage
of the current Tracker. We end by 'saving' the changes and cancelling
the current request

Store temporary information in sitecore

I've a doubt about the best practices related with Sitecore.
I will need to store a form information when the user presses Save button while he's still filling all the form before submit. Therefore, in case he goes to the website in the next day he will see the already filled information and he can submit.Because the form is long and splitted in four steps.
My doubt is more related with the best practices for Sitecore. Where should I store this information?
Should I create a table inside sitecore_core or other existing database and read from there? (If there's any way to do that with Sitecore libs)
Or should I create my own database, probably with just two tables, to store that information?
Thanks
You should create your own database and store the information there. It is no best practice to add tables to the Sitecore databases and storing this information inside one of the existing tables (ie Sitecore items) is also not the way to go.
So just go for the custom database.
If you are using user profiles and (xdb) analytics data and want to store the form data there anyway, that could also be an option (using a custom facet).
You should use WFFM for saving any form information. In case if you want to send/save any additional information then you add your custom save action. Like for example we save data from the contact us form and newsletter form to Eloqua or Marketo for other purposes using custom action.

How to load different content for the same language in sitecore

I have a requirement where user would like to display different content for different states within the same country.To be clear i have added (en-us) language version to an item which would display single content to "Florida" state, now they would like to display different content(Image,title,etc..) for "texas" state how we can achieve this? thanks in advance.
You can achieve this by personalizing your content, not by adding different content for each item using the same language.
To show different content (Images, Title, etc) for each state, you can use Sitecore personalization rules "Out of the box".
One of the approaches you can use, and it is very easy to implement:
Define content for each state, maybe in the Global folder.
Go to experience editor, and personalize the rendering components.
Create new Condition - use the existing rule "Where the City Compares to Specific City".
You can get the list of cities that you can use from this URL: http://www.maxmind.com/GeoIPCity-534-Location.csv Sitecore uses this services.
As Ahmad answer use the personalization rules engine to add conditions that personalize your content based on, but I believe if you are using a Sitecore 8.1 and up you can use Sitecore IP Geolocation service.
Sitecore IP Geolocation provides information about the location and owner of an IP address beyond that provided by a reverse DNS lookup. IP Geolocation information includes the country, state, city, and the registered company name of every visitor.
Adding to #Ahmad's answer.
If you want to use condition like "city is equal to texas" u need to enable Sitecore GeoIP services first. This is a paid service from sitecore which uses Maxmind's GeoIP in the background.
There is one more option, where you can create new languages in sitecore like en-texas and en-florida. Once you created new languages you can use them like normal sitecore languages. So content editors can fill in different content for those languages.

User valuelookup in Sitecore 6?

I have some Extranet users. Each user has a dedicated page/item, that is maintained by the Admins. The Admins should manually be able to "connect"/reference the current item to a single extranet user. I am think of something like using a valuelookup type or similar on the template.
But how could i accomblish this, as the users are stored in ASP.NET membership, and not directly in Sitecore, as they were in previous versions of Sitecore.
I think you've got the right idea. Either store the users's full name (Domain\UserName) in the item, or store the item ID in the user's profile. If you go the Profile route, be sure and update Sitecore's User template in the Core DB so that you can see the value in the user manager.
There's also a Sitecore table you could use called IDTable which is normally used for mapping Sitecore item IDs to external data. That might be your best solution since user Profiles can be annoying... will also be the most efficient in terms of finding/indexing this data. Look at the Sitecore examples of importing data to get an example using this API.