Innkeepr
Home
  • Home
    • Welcome to Innkeepr
    • Getting Started
  • Guides
    • A Basic Installation
    • Server-Side Installation
  • Connections
    • Overview
    • The Innkeepr Spec
      • Spec: Identify
      • Spec: Track
      • Spec: Ecommerce Events
    • Sources Catalog
      • Innkeepr.js
      • Google Ads
      • Google Analytics 4
      • Meta Ads
      • Shopify
      • TikTok Ads
  • References
    • Audiences
    • Events
      • Standard events
      • Custom events
  • Support
    • Resources
      • Cookie Consent
      • Data Protection Statement
    • FAQ
    • Contact
Powered by GitBook
On this page
  • Collecting Anonymous IDs
  • Collecting Session IDs
  • Sending Conversions Events
  • Summary
  1. Guides

Server-Side Installation

PreviousA Basic InstallationNextOverview

Last updated 7 months ago

This guide walks you through how to set up server-side conversion tracking with Innkeepr. This involves collecting a visitors anonymousId and sessionId on the client side, and sending conversion event via Events API.

Make sure that Innkeepr.js is still running on the client side. The script is mandatory for persisting and managing anonymousId and sessionId.

Learn More

Collecting Anonymous IDs

The anonymousId is a unique identifier used to track anonymous users. This ID is generated and managed by Innkeepr.js.

Steps:

  1. Retrieve the anonymousId: Use the provided function from Innkeepr.js to get the anonymousId of the current user.

    var anonymousId = window.Innkeepr.anonymousId();

Collecting Session IDs

The sessionId is used to track user interactions during a specific session. This ID is also managed by Innkeepr.js.

Steps:

  1. Retrieve the session ID: Use the provided function from the Innkeepr.js to get the sessionId of the current user.

    var sessionId = window.Innkeepr.userSession.sessionId;

Sending Conversions Events

Once you have collected the anonymousId and the sessionId, you can send the conversion event to the Event API.

Steps:

  1. Prepare the Data: Ensure that the anonymousId, sessionId, and other necessary information are included in your conversion event. Here is an example structure of the event:

    var event = {
        content: {
            name: "EVENT_NAME",
            profileId: null, // Optional, if available
            email: null, // Placeholder for the actual email
            anonymousId: anonymousId,
            sessionId: sessionId,
            created: new Date().toISOString(),
            properties: {
                // Add additional properties of the conversion event here
            },
            type: "track",
            meta: {
                app: null, // Optional, if available
                library: {
                    name: "innkeepr.js",
                    version: "1.0"
                },
                locale: "de-DE",
                os: {
                    name: "Windows", // Example value
                    browser: "Chrome", // Example value
                    fullVersion: "79.0.3945.130", // Example value
                    majorVersion: 79, // Example value
                    appName: "Netscape", // Example value
                    language: "de-DE"
                },
                page: {
                    path: "/auth",
                    referrer: "http://localhost:4200/auth",
                    search: "",
                    title: "Innkeepr",
                    url: "http://localhost:4200/auth"
                },
                session: sessionId,
                traits: {},
                userAgent: navigator.userAgent // Current user agent
            }
        },
        context: {
            apikey: "{{API_KEY}}" // Replace {{API_KEY}} with your actual API key
        }
    };
  2. Send the Data to the Event API: Use fetch to send the data to the Event API.

    fetch('https://api.innkeepr.ai/api/v1/track', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(event)
    })
    .then(response => response.json())
    .then(data => {
        console.log('Success:', data);
    })
    .catch((error) => {
        console.error('Error:', error);
    });

Summary

By following these steps, you can set up server-side conversion tracking with Innkeepr. Ensure that you correctly capture the anonymousId and sessionId and properly send the conversion event to the Event API to obtain accurate and useful analytics.

A Basic Installation