DATA Reshape Documentation

website·Indexed 32 days ago

https://kb.datareshape.ro

Technical documentation for DATA Reshape, covering event tracking, custom integrations, and destination setup. Includes detailed payload references for e-commerce events like checkout_completed, cart_viewed, and product_viewed, as well as configuration guides for Google Ads, Google Analytics 4, Meta (Facebook) Pixel, and TikTok.

Tokens
72.8K
Snippets
239
Records
383
Agent score
53%

What's inside DATA Reshape

  1. Overview of DATA Reshape Destinations

    Destinations are the analytics, advertising platforms, or custom systems where DATA Reshape delivers processed tracking data. The delivery process follows these steps: events are collected via tracking scripts or webhooks, processed and enriched by DATA Reshape, and then delivered server-side to destinations based on the account configuration mapping.
  2. Define the context object for API requests

    The context object is required and provides metadata about the environment and the user's session/device.
    {
      "context": {
        "environment": "prod", // string (required): 'prod' or 'dev'
        "data_source": "website", // string (recommended): 'website', 'phone', 'admin', 'app', 'marketplace'
        "user_agent": "Mozilla/5.0...", // string (recommended)
        "override_ip": "203.0.113.1", // string (recommended) - IPv4 or IPv6
        "url": "https://example.com/thank-you", // string (recommended)
        "landing_url": "https://example.com/landing-page", // string (recommended)
        "referrer_url": "https://example-search.com" // string (recommended)
      }
    }
  3. Send events to DATA Reshape via the Event Create API

    The /webhooks/reshape/event endpoint is a universal API for server-side tracking of e-commerce, CRM, and enterprise application events. It supports production and testing environments to validate payloads synchronously.
    POST /webhooks/reshape/event
    Content-Type: application/json
  4. Understand DATA Reshape consent enforcement and default state

    DATA Reshape acts as a gatekeeper for all data flowing to connected destinations. By default, all visitors start in a default-denied state for analytics, personalization, and marketing. Tracking runs in a GDPR-restricted mode until an explicit consent signal is received. Consent is enforced automatically across all destinations, removing the need for per-destination privacy logic.
  5. Configure event context parameters

    The context object provides environmental data about where the event occurred. Be cautious of including sensitive personal identifiers or session tokens in the url query parameters to comply with privacy regulations.
    context: {
      url: "https://example.com/",
      page_type: "product", // e.g., 'product', 'home'
      environment: "prod"   // Allowed values: 'prod', 'dev'
    }
  6. Implement Context Web Object updates for SPA route changes

    In Single Page Applications, the browser URL does not trigger automatic page context updates. You must manually push a new event with the updated url and context on every route change.
    // On each SPA route change, push a new event with the current route URL
    window.reshape = window.reshape || [];
    reshape.push({
      event: {
        name: "page_viewed"
      },
      context: {
        url: currentRouteUrl, // Current route URL from your framework's router
        page_type: "dashboard",
        environment: "prod"
      }
    });
  7. Manually install DATA Reshape via theme header.php

    This method works across all WordPress configurations but is susceptible to being overwritten during theme updates. Add the tracking script immediately before the closing </head> tag in the header.php file.
    <!-- DATA Reshape Tracking Code -->
    <script>
    (function(R,e,s,h,a,p,E){
      var b=R.Reshape=R.Reshape||{};
      b.setCookie=function(n,v,t,d){try{e.cookie=n+'='+v+';max-age='+t+';domain='+d+';path=/;SameSite=None;Secure';}catch(e){}};
      b.id=a;b.cdn=h;b.sts=new Date().getTime();
      E=e.getElementsByTagName(s)[0];p=e.createElement(s);p.async=true;p.src="https://"+h+"/main.js?id="+a;E.parentNode.insertBefore(p,E);
    })(window,document,"script","dre2.YOUR_DOMAIN.TLD","YOUR_SCRIPT_ID");
    </script>
  8. Use custom product properties for audience segmentation

    The properties object within a product allows for free-form key-value pairs used for advanced segmentation and personalization in marketing campaigns. This is particularly useful for attributes like color, size, material, or technical specifications.
    // Example for Electronics
    properties: {
      color: "space_gray",
      storage: "256GB", 
      memory: "16GB",
      connectivity: ["wifi", "bluetooth"],
      warranty: "2_years"
    }
    
    // Example for Fashion
    properties: {
      color: ["black", "white"],
      size: "M",
      material: "cotton",
      fit: "regular"
    }
  9. Trigger the user_updated event for profile changes

    The user_updated event is triggered when an authenticated user modifies profile information (name, address, marketing preferences). To ensure data synchronization across downstream destinations, follow these best practices:

    1. Send the full identity: Include all known user fields, not just the changed ones.
    2. Include user.id: This is required to match the update to an existing profile.
    3. Fire on save: Trigger the event upon form submission/save, not on every keystroke.
    4. Use update_type: Capture the type of update in event.properties for better analytics segmentation.
    5. Prefer server-side: Fire the event from your account-update handler for maximum reliability.
    window.reshape = window.reshape || [];
    reshape.push({
      "event": {
        "name": "user_updated",
        "value": 0,
        "currency": "USD",
        "id": "userupd_abc123",
        "properties": { "update_type": "preferences_change" }
      },
      "context": {
        "url": "https://example.com/account/preferences",
        "page_type": "account",
        "environment": "prod"
      },
      "user": {
        "id": "cust_abc123",
        "email": "example.customer@example.com",
        "country": "US",
        "properties": {
          "marketing_consent": false,
          "preferred_language": "en",
          "preferred_categories": ["apparel", "accessories"]
        }
      }
    });
  10. Implement the lead_closed event for sales pipeline tracking

    The lead_closed event should be fired when a lead reaches a final stage in the sales pipeline (e.g., Closed Won or Closed Lost). This serves as a bottom-of-funnel signal for B2B and high-consideration purchases. It is typically fired server-side from a CRM. To allow destinations to compute true ROAS, use the same event.id as the original lead_created event.

    DATA Reshape automatically maps this single event to multiple destinations:

    • Google Ads: Uploaded as an offline conversion using transaction_id from event.id and Enhanced Conversions from the user object.
    • Meta Pixel / Conversions API: Sent as a custom CamelCase event (e.g., LeadClosed, LeadClosedWon, or LeadClosedLost).
    • TikTok Pixel / Events API: Sent as a custom CamelCase event LeadClosed.
    • GA4: Mapped as a custom event.
  11. Track shipping method selection with shipping_detail_added

    Fire the shipping_detail_added event when a visitor selects or confirms a shipping method (e.g., standard, express, store pickup) during checkout. This event should be triggered once per confirmed selection; if a user changes their shipping method, fire the event again.

    DATA Reshape automatically maps this single event to multiple native platform events:

    • Google Analytics 4: add_shipping_info
    • TikTok Pixel / Events API: AddShippingInfo
    • Meta: Custom CamelCase event AddShippingInfo (when connected).
    {
      "event": {
        "name": "shipping_detail_added"
      }
    }