In a nutshell, you must make sure that
Xdb.Tracking.Enabled setting is set to
true and that you have
VisitorIdentification in your layout.
More details from Sitecore documentation site ( https://doc.sitecore.com/developers/91/sitecore-experience-platform/en/enabling-tracking.html )
To enable tracking:
Ensure that Xdb.Tracking.Enabled is set to true - see the Experience Manager documentation for more information.
Ensure that layouts contain the VisitorIdentification tag or MVC helper.
If you are using ASP.NET MVC, use the MVC helper:
- If you are using ASP.NET Web Forms use the following tag:
As @Trayek mentioned in his comment, Sitecore by default doesn't index anonymous contacts. It means that anonymous contacts data is stored but it's not displayed e.g. in Experience Profile application.
In Sitecore 8.2 you can use the setting:
<setting name="ContentSearch.Analytics.IndexAnonymousContacts" value="true"/>
If you use Sitecore 9 you should look at this article as well https://doc.sitecore.com/developers/91/sitecore-experience-platform/en/enable-indexing-of-anonymous-contacts.html
If you want to identify a contact, use
More about contact identification in Sitecore docs: https://doc.sitecore.com/developers/91/sitecore-experience-platform/en/identifying-contacts.html