# Adobe Analytics

Send Shoplift test data to Adobe Analytics using eVars and custom events for enterprise-grade analysis.

### Quick Start

Add this code to your Adobe Analytics implementation:

```javascript
// Adobe Analytics + Shoplift Integration
function initializeShopliftAdobe() {
  if (window.shoplift && window.s) {
    const visitorData = window.shoplift.getVisitorData();
    
    if (visitorData.visitor && visitorData.visitorTests.length > 0) {
      // Process each test assignment
      visitorData.visitorTests.forEach((test, index) => {
        // Set eVars (adjust numbers based on your configuration)
        s.eVar60 = test.testId;                    // Test ID
        s.eVar61 = test.hypothesisId;              // Variant ID
        s.eVar62 = test.isThemeTest ? 'theme' : 'element'; // Test type
        
        // Set props for traffic variables
        s.prop60 = visitorData.visitor.id;         // Visitor ID
        s.prop61 = visitorData.visitor.device;     // Device type
        
        // Set list variable for multiple tests
        if (index === 0) {
          s.list1 = `${test.testId}:${test.hypothesisId}`;
        } else {
          s.list1 += `,${test.testId}:${test.hypothesisId}`;
        }
      });
      
      // Track test exposure event
      s.events = s.apl(s.events, 'event60', ',', 1);
      
      // Send the beacon
      s.tl(true, 'o', 'Shoplift Test Exposure');
    }
  } else {
    setTimeout(initializeShopliftAdobe, 100);
  }
}

// Initialize on page load
initializeShopliftAdobe();
```

### Configuration Notes

#### eVar Setup

Configure these eVars in Adobe Analytics:

* **eVar60**: Test ID (Expiration: Visit)
* **eVar61**: Variant ID (Expiration: Visit)
* **eVar62**: Test Type (Expiration: Hit)

#### Event Setup

* **event60**: Test Exposure (Counter)

#### Processing Rules

Create processing rules to:

1. Persist test data across all hits in a visit
2. Populate merchandising eVars for product-specific tests
3. Set success events based on test participation

### Advanced Implementation

#### Track Purchase Attribution

```javascript
// On order confirmation page
if (window.Shopify && Shopify.checkout) {
  const visitorData = window.shoplift.getVisitorData();
  
  s.products = Shopify.checkout.line_items.map(item => 
    `;${item.sku};;;;eVar60=${visitorData.visitorTests[0]?.testId}|eVar61=${visitorData.visitorTests[0]?.hypothesisId}`
  ).join(',');
  
  s.events = 'purchase';
  s.purchaseID = Shopify.checkout.order_id;
  s.t();
}
```

### Analysis in Adobe Workspace

Create calculated metrics for:

* Conversion rate by test variant
* Revenue per visitor by test
* Average order value by variant
* Test influence on customer lifetime value
