Method Attx.subscription()
Use this method to send subscription events to the AttributionIQ system.
Syntax
Attx.subscription(payload, onSuccess)
Parameters
payload (Object, required)
An object with subscription data containing the following fields:
Field | Type | Required | Description |
| string | Yes | Subscriber's email |
| number | Yes | Subscription amount |
| string | Yes | Currency: |
| string | Yes | Subscription status: |
| string | No | Subscription ID (if available) |
| string | No | Subscription type (e.g., "monthly", "yearly") |
| timestamp | Yes* | Trial period end date |
| timestamp | No | Subscription creation date |
onSuccess (Function, optional)
Callback function that is called after the event is successfully sent to the server.
Usage Examples
Active subscription
Attx.subscription({
email: 'user@example.com',
amount: 29.99,
currency: 'USD',
status: 'active',
subscriptionId: 'sub_1234567890',
type: 'monthly'
});
Trial period
Attx.subscription({
email: 'trial@example.com',
amount: 99.99,
currency: 'EUR',
status: 'in_trial',
trialEnd: Date.now() + (14 * 24 * 60 * 60 * 1000), // +14 days
subscriptionId: 'sub_9876543210',
type: 'yearly'
});
With callback function
Attx.subscription(
{
email: 'customer@company.com',
amount: 499,
currency: 'GBP',
status: 'active',
subscriptionId: 'sub_enterprise_001',
type: 'enterprise',
createdAt: Date.now()
},
(response) => {
console.log('Subscription successfully registered', response);
// Redirect to success page
window.location.href = '/thank-you';
}
);