REST API Overview
PersonalizeWP REST API: Overview
PersonalizeWP Pro includes a powerful REST API that allows developers to access visitor data and create personalized experiences on WordPress websites. This documentation provides a comprehensive guide to utilizing these API endpoints.
Available Endpoints
PersonalizeWP Pro offers the following REST API endpoints:
- Visitor Activities (
/wp-json/personalizewp/v1/visitor-activities
)- Retrieve all recorded activities for a specific visitor
- Filter activities by various parameters
Use this data to create personalized experiences based on user behavior
Visitor Segments (
/wp-json/personalizewp/v1/visitor-segments
)- Retrieve all active segments that a visitor belongs to
- Use segment data to deliver targeted content to specific user groups
Authentication
The PersonalizeWP REST API endpoints are accessible on the frontend without authentication, as they are designed to work with the current visitor's data. The endpoints require the visitor's unique identifier (UID) which is stored in the browser's local storage.
Basic Usage
To use the PersonalizeWP REST API:
- Retrieve the visitor's UID from local storage
- Make POST requests to the desired endpoint
- Process the returned data to create personalized experiences
Getting the Visitor's UID
Before making any API requests, you need to retrieve the visitor's unique identifier (UID) which is stored in the browser's local storage:
const PWP = localStorage.getItem('pwp_tracked_user') || ''; const UID = (PWP) ? JSON.parse(PWP).id : null;
This UID is essential for all API requests as it identifies the specific visitor whose data you want to access.
Use Cases
The PersonalizeWP REST API enables a wide range of personalization features, including:
- Displaying recently viewed products
- Creating personalized product recommendations
- Showing content based on visitor segments
- Building custom personalization features
For detailed information on each endpoint and implementation examples, please refer to the specific documentation articles: