Skip to content

Getting Started

This guide walks you through integrating InsightCore analytics into your web application.

Prerequisites

  • An OAuth client registered with the Identity API
  • A website or web application to track
  • Access to your site's HTML or template system

Step 1: Obtain an Access Token

Request an OAuth token from the Identity service with InsightCore scopes:

bash
curl -X POST https://identity.retailsuccessplatform.com/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=${CLIENT_ID}" \
  -d "client_secret=${CLIENT_SECRET}" \
  -d "scope=insightcore:settings.write insightcore:reports.read"
json
{
  "token_type": "Bearer",
  "expires_in": 3600,
  "access_token": "eyJhbGciOiJSUzI1NiIs..."
}

Store this token securely on your backend. Management and reporting API calls should be made server-side.

Step 2: Register Your Site

Create a site configuration with your allowed domains:

bash
curl -X POST https://api.insightcore.retailsuccessplatform.com/api/v1/settings \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "site_name": "My Online Store",
    "allowed_domains": ["mystore.com", "www.mystore.com"]
  }'
json
{
  "data": {
    "setting_id": "stg_00000k1L2m3N4o5",
    "site_name": "My Online Store",
    "allowed_domains": ["mystore.com", "www.mystore.com"],
    "organization_id": "org_00000a1B2c3D4e5",
    "created_at": "2026-03-26T12:00:00Z"
  }
}

The organization_id is what you'll use in the JavaScript tag.

Step 3: Install the JavaScript Tag

Add the InsightCore analytics tag to every page of your site, just before the closing </body> tag:

html
<script>
  var rspaq = rspaq || [];
  rspaq.push(['init', 'org_00000a1B2c3D4e5']);
</script>
<script async src="https://api.insightcore.retailsuccessplatform.com/api/v1/tag/rsp-analytics.js"></script>

The tag automatically captures:

  • Page views — including SPA navigations (History API)
  • Scroll depth — maximum scroll percentage per page
  • Clicks — link and button interactions
  • Form submissions — form submit events

Events are batched and sent every 3 seconds, or immediately on page unload via sendBeacon.

Step 4: Track Ecommerce Events (Optional)

For ecommerce tracking, push custom events from your application code:

javascript
// Product viewed
rspaq.push(['trackEvent', 'product_view', {
  product_id: 'prd_00000k1L2m3N4o5',
  product_name: 'Organic Bananas',
  product_price: 2.99,
  product_category: 'Produce'
}]);

// Added to cart
rspaq.push(['trackEvent', 'add_to_cart', {
  product_id: 'prd_00000k1L2m3N4o5',
  product_name: 'Organic Bananas',
  product_price: 2.99,
  quantity: 2
}]);

// Purchase completed
rspaq.push(['trackEvent', 'purchase', {
  order_total: 47.85,
  items: [
    { product_id: 'prd_00000k1L2m3N4o5', quantity: 2, price: 2.99 },
    { product_id: 'prd_00000x9Y8w7V6u5', quantity: 1, price: 41.87 }
  ]
}]);

Step 5: Query Reports

Fetch analytics data from your backend for display in your admin panel:

bash
# Overview report
curl "https://api.insightcore.retailsuccessplatform.com/api/v1/analytics/reports/overview?from=2026-03-01&to=2026-03-26" \
  -H "Authorization: Bearer ${TOKEN}"

# Top pages
curl "https://api.insightcore.retailsuccessplatform.com/api/v1/analytics/reports/pages?from=2026-03-01&to=2026-03-26&sort=-views" \
  -H "Authorization: Bearer ${TOKEN}"

# Real-time active visitors
curl "https://api.insightcore.retailsuccessplatform.com/api/v1/analytics/realtime/active-visitors" \
  -H "Authorization: Bearer ${TOKEN}"

Step 6: Set Up Conversion Funnels (Optional)

Define a funnel to track conversion rates through a multi-step flow:

bash
curl -X POST https://api.insightcore.retailsuccessplatform.com/api/v1/funnels \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Checkout Funnel",
    "steps": [
      { "name": "Product View", "event_type": "product_view" },
      { "name": "Add to Cart", "event_type": "add_to_cart" },
      { "name": "Checkout", "event_type": "checkout" },
      { "name": "Purchase", "event_type": "purchase" }
    ]
  }'

Then analyze funnel performance:

bash
curl "https://api.insightcore.retailsuccessplatform.com/api/v1/funnels/fnl_00000k1L2m3N4o5/analyze?from=2026-03-01&to=2026-03-26" \
  -H "Authorization: Bearer ${TOKEN}"

Next Steps


Changelog
DateChange
2026-03-26Initial publication.

ShopHero CommerceCore Platform