Services / Visitor API / Getting Started with Visitor API
Getting Started with Visitor API

This getting started section guides you through a process of creating a Web API application to get the visitor data using the Vissitor API.

Add Visitor API to Server API

  1. Create a new Web API Core application.
  2. Add the C1.AspNetCore.Api.Visitor NuGet package to the application.

Configure the API

You can choose to configure the API either using IP2Location Database or GoogleMap API. To configure the api using the IP2Location Database, see Configuring IP2Location Database. If you want to configure the API using the GoogleMap API, see Configuring Google Map API.

Note that you can set the following in ConfigureServices method of startup.cs file, if you do not want to use any location provider. This will allow you to use all other visitor information.

script
Copy Code
services.ConfigureVisitor(builder =>
       {

               builder.UseWithoutLocationProvider();

       });

Include JS Client Script to Client Project

For synchronous loading of visitor data, use the following code.

script
Copy Code
<script src="{host}/api/visitor/visitor-client.min.js"></script>

Access Visitor Information

To get the complete visitor data, use the following code:

var visitorData= window.visitor.getData();

For detailed list of the visitor data fetched on the client-side, see Visitor Data Information.