Using the Fullstory API to Get Page Analytics (with Python examples)

by Endgrate Team 2024-08-27 5 min read

Fullstory homepage

Introduction to Fullstory API for Page Analytics

Fullstory is a powerful analytics platform that provides deep insights into user interactions on your website. By capturing and analyzing user sessions, Fullstory helps businesses understand user behavior, optimize user experience, and improve conversion rates.

Developers may want to integrate with Fullstory's API to access detailed page analytics, enabling them to create custom reports or dashboards. For example, a developer might use the Fullstory API to retrieve page view data and analyze user engagement patterns, helping the marketing team tailor content strategies.

Setting Up Your Fullstory API Test Account

Before diving into Fullstory API integration, you need to set up a test account to experiment with API calls and gather page analytics data. Fullstory offers a straightforward process to get started with their API using an API key for authentication.

Creating a Fullstory Account

If you don't already have a Fullstory account, you can sign up for a free trial on the Fullstory website. This will give you access to the platform's features and allow you to generate an API key for testing purposes.

  • Visit the Fullstory website and click on the "Start Free Trial" button.
  • Fill in the required information to create your account.
  • Once your account is set up, log in to access the Fullstory dashboard.

Generating a Fullstory API Key

To interact with the Fullstory API, you'll need an API key with the appropriate permissions. Follow these steps to create one:

  • Navigate to the "Settings" section in the Fullstory dashboard.
  • Click on "API Keys" to view and manage your keys.
  • Click the "Create key" button in the top-right corner of the keys list.
  • Enter a meaningful name for your key and select the permission level. For accessing page analytics, ensure you have Admin or Architect level permissions.
  • Click "Save API Key" to generate the key. A modal will appear with the new key’s value. Copy this value and store it securely, as you won't be able to view it again.

For more details on managing API keys, refer to the Fullstory Developer Guide.

Configuring API Key Authentication

Once you have your API key, you can use it to authenticate your API requests. The API key should be included in the Authorization header of your requests as follows:

headers = {
    "Authorization": "Basic YOUR_API_KEY"
}

Replace YOUR_API_KEY with the key you generated. This setup will allow you to make authorized requests to the Fullstory API and retrieve page analytics data.

Fullstory authentication documentation page.
sbb-itb-96038d7

Making API Calls to Retrieve Page Analytics with Fullstory and Python

To effectively interact with Fullstory's API and retrieve page analytics, you'll need to use Python to make HTTP requests. This section will guide you through the necessary steps, including setting up your environment, writing the code, and handling potential errors.

Setting Up Your Python Environment for Fullstory API Integration

Before you start coding, ensure you have Python installed on your machine. This tutorial uses Python 3.11.1. Additionally, you'll need the requests library to handle HTTP requests. Install it using pip:

pip install requests

Writing Python Code to Fetch Page Analytics from Fullstory

Once your environment is ready, create a Python script to make API calls to Fullstory. Below is an example of how to retrieve page analytics using the Fullstory API:

import requests

# Define the API endpoint and headers
segment_id = "your_segment_id"
url = f"https://api.fullstory.com/segments/v1/{segment_id}"
headers = {
    "Authorization": "Basic YOUR_API_KEY",
    "Accept": "application/json"
}

# Make a GET request to the Fullstory API
response = requests.get(url, headers=headers)

# Check if the request was successful
if response.status_code == 200:
    data = response.json()
    print("Segment Information:", data)
else:
    print("Failed to retrieve data:", response.status_code, response.text)

Replace YOUR_API_KEY with your actual API key and your_segment_id with the segment ID you wish to analyze. This script sends a GET request to the Fullstory API and prints the segment information if successful.

Verifying Successful API Requests and Handling Errors

After running your script, verify the output to ensure the data matches the expected results in your Fullstory account. If the request fails, the script will print the error code and message. Common error codes include:

  • 401 Unauthorized: Check your API key and permissions.
  • 404 Not Found: Verify the segment ID is correct.
  • 500 Internal Server Error: Retry the request or contact Fullstory support.

For more detailed error handling, refer to the Fullstory API documentation.

Fullstory API call documentation page.

Conclusion and Best Practices for Using Fullstory API with Python

Integrating with the Fullstory API to access page analytics can significantly enhance your ability to understand user interactions and improve your website's performance. By following the steps outlined in this guide, you can efficiently retrieve and analyze data using Python.

Best Practices for Fullstory API Integration

  • Secure API Key Storage: Always store your API keys securely. Consider using environment variables or a secure vault to keep them safe.
  • Handle Rate Limiting: Be mindful of any rate limits imposed by Fullstory. Implement exponential backoff strategies to handle rate limit errors gracefully.
  • Data Transformation: Standardize and transform data fields as needed to ensure consistency across your analytics and reporting tools.
  • Error Handling: Implement robust error handling to manage different HTTP status codes and provide meaningful feedback to users or systems.

Streamlining Integrations with Endgrate

While integrating with Fullstory's API can be powerful, managing multiple integrations can become complex. Endgrate offers a unified API solution that simplifies the integration process across various platforms, including Fullstory. By using Endgrate, you can save time and resources, allowing you to focus on your core product development.

Explore how Endgrate can enhance your integration strategy by visiting Endgrate and discover a more efficient way to manage your integrations.

Read More

Ready to get started?

Book a demo now

Book Demo