---
updatedAt: 2026-03-06T00:36:16.000Z
agentTools:
  projectIndex: https://docs.pelcro.com/v2.4/llms.txt
---

# Modules

Complete reference for all SDK modules, methods, parameters, and return values

## Overview

The Pelcro JavaScript SDK exposes modules on the global `window.Pelcro` object. Each module provides methods for interacting with specific Pelcro platform features.

All async methods use the callback pattern: `(error, data) => {}`. On success, `error` is `null` and `data` contains the response. On failure, `error` contains the error object and `data` is `null`.

```javascript
Pelcro.user.login({ email: "user@example.com", password: "secret" }, (err, data) => {
  if (err) { console.error("Failed:", err); return; }
  console.log("Success:", data);
});
```

***

***

## Initialization

Modules become available after the SDK loads. Use boot events to guarantee access:

```javascript
document.addEventListener("PelcroSiteLoaded", () => {
  const site = Pelcro.site.read();
});

document.addEventListener("PelcroBootComplete", () => {
  if (Pelcro.user.isAuthenticated()) {
    const user = Pelcro.user.read();
  }
});
```

***

***

## Site

Provides access to site configuration and settings loaded during SDK initialization.

### read

```javascript
Pelcro.site.read()
```

Returns the cached site configuration object.

* **Returns:** `Object` - Site configuration including products, plans, settings, and paywall rules.

### getById

```javascript
Pelcro.site.getById(callback)
```

Fetches site configuration from the API. Called automatically during boot.

| Parameter | Type     | Required | Description     |
| --------- | -------- | -------- | --------------- |
| callback  | Function | Yes      | `(error, data)` |

***

***

## User

Handles user authentication, registration, profile management, and session state.

### read

```javascript
Pelcro.user.read()
```

Returns the cached user object.

* **Returns:** `Object` - The current user data including `id`, `email`, `auth_token`, `subscriptions`, `addresses`, `invoices`, etc.

### isAuthenticated

```javascript
Pelcro.user.isAuthenticated()
```

Checks whether a user is currently logged in.

* **Returns:** `Boolean`

### register

```javascript
Pelcro.user.register(options, callback)
```

Registers a new user account.

| Parameter           | Type     | Required | Description     |
| ------------------- | -------- | -------- | --------------- |
| options.email       | String   | Yes      | User email      |
| options.password    | String   | Yes      | User password   |
| options.first\_name | String   | No       | First name      |
| options.last\_name  | String   | No       | Last name       |
| callback            | Function | Yes      | `(error, data)` |

**Events fired:** `PelcroUserRegistered`, `PelcroUserLoaded`

### login

```javascript
Pelcro.user.login(options, callback)
```

Authenticates a user with email and password.

| Parameter        | Type     | Required | Description     |
| ---------------- | -------- | -------- | --------------- |
| options.email    | String   | Yes      | User email      |
| options.password | String   | Yes      | User password   |
| callback         | Function | Yes      | `(error, data)` |

**Events fired:** `PelcroUserLoggedIn` (with `loginType: "email"`), `PelcroUserLoaded`

### idpLogin

```javascript
Pelcro.user.idpLogin(options, callback)
```

Authenticates a user via an Identity Provider (Google, Facebook, etc.).

| Parameter           | Type     | Required | Description                                   |
| ------------------- | -------- | -------- | --------------------------------------------- |
| options.idp\_name   | String   | Yes      | Provider name (e.g. `"google"`, `"facebook"`) |
| options.idp\_token  | String   | Yes      | OAuth token from the provider                 |
| options.email       | String   | Yes      | User email                                    |
| options.first\_name | String   | No       | First name                                    |
| options.last\_name  | String   | No       | Last name                                     |
| callback            | Function | Yes      | `(error, data)`                               |

**Events fired:** `PelcroUserLoggedIn` (with `loginType: "IDP"`), `PelcroUserLoaded`

### authenticate

```javascript
Pelcro.user.authenticate(callback)
```

Re-authenticates the current session using the stored auth token. Called automatically during boot if a token exists.

| Parameter | Type     | Required | Description     |
| --------- | -------- | -------- | --------------- |
| callback  | Function | Yes      | `(error, data)` |

**Events fired:** `PelcroUserLoggedIn`, `PelcroUserLoaded`

### logout

```javascript
Pelcro.user.logout()
```

Logs out the current user by clearing the auth token and resetting user state.

**Events fired:** `PelcroUserLogout`

### update

```javascript
Pelcro.user.update(options, callback)
```

Updates the current user profile.

| Parameter             | Type     | Required | Description     |
| --------------------- | -------- | -------- | --------------- |
| options.auth\_token   | String   | Yes      | Auth token      |
| options.first\_name   | String   | No       | First name      |
| options.last\_name    | String   | No       | Last name       |
| options.email         | String   | No       | Email           |
| options.phone         | String   | No       | Phone number    |
| options.display\_name | String   | No       | Display name    |
| callback              | Function | Yes      | `(error, data)` |

**Events fired:** `PelcroUserUpdated`

### convert

```javascript
Pelcro.user.convert(options, callback)
```

Converts a guest/anonymous user into a registered user by setting a password.

| Parameter                      | Type     | Required | Description           |
| ------------------------------ | -------- | -------- | --------------------- |
| options.email                  | String   | Yes      | User email            |
| options.password               | String   | Yes      | Password              |
| options.password\_confirmation | String   | Yes      | Password confirmation |
| callback                       | Function | Yes      | `(error, data)`       |

### uploadProfilePicture

```javascript
Pelcro.user.uploadProfilePicture(options, callback)
```

Uploads a profile picture for the current user.

| Parameter           | Type     | Required | Description     |
| ------------------- | -------- | -------- | --------------- |
| options.auth\_token | String   | Yes      | Auth token      |
| options.image       | File     | Yes      | Image file      |
| callback            | Function | Yes      | `(error, data)` |

### removeProfilePicture

```javascript
Pelcro.user.removeProfilePicture(options, callback)
```

Removes the current user profile picture.

| Parameter           | Type     | Required | Description     |
| ------------------- | -------- | -------- | --------------- |
| options.auth\_token | String   | Yes      | Auth token      |
| callback            | Function | Yes      | `(error, data)` |

### saveToMetaData

```javascript
Pelcro.user.saveToMetaData(options, callback)
```

Saves a key-value pair to the user metadata. The key is stored with a `metadata_` prefix.

| Parameter     | Type     | Required | Description     |
| ------------- | -------- | -------- | --------------- |
| options.key   | String   | Yes      | Metadata key    |
| options.value | String   | Yes      | Metadata value  |
| callback      | Function | Yes      | `(error, data)` |

**Events fired:** `PelcroMetadataUpdated`

### isEntitledTo

```javascript
Pelcro.user.isEntitledTo(entitlement)
```

Checks if the user is entitled to a specific content entitlement through their subscriptions.

* **Returns:** `Boolean`

### hasOrdered

```javascript
Pelcro.user.hasOrdered()
```

Checks if the user has any ecommerce orders.

* **Returns:** `Boolean`

### resendEmailVerification

```javascript
Pelcro.user.resendEmailVerification(options, callback)
```

Resends the email verification link.

### verifyEmailToken

```javascript
Pelcro.user.verifyEmailToken(options, callback)
```

Verifies the user email using the token from the verification link.

### requestLoginToken

```javascript
Pelcro.user.requestLoginToken(options, callback)
```

Requests a passwordless login token sent to the user email.

### verifyLoginToken

```javascript
Pelcro.user.verifyLoginToken(options, callback)
```

Verifies a passwordless login token.

### location

```javascript
Pelcro.user.location
```

Object containing the user detected location: `countryCode`, `countryName`, `regionCode`, `city`.

***

***

## Location

Provides IP-based geolocation with session caching.

### get

```javascript
Pelcro.user.location.get(callback)
```

Fetches the user location from the API. Caches the result in session storage.

***

***

## Paywall

Controls paywall display, metering, and content restriction logic.

### read

```javascript
Pelcro.paywall.read()
```

Returns the active paywall configuration for the current page context.

* **Returns:** `Object|null`

### getProduct

```javascript
Pelcro.paywall.getProduct()
```

Returns the product whose paywall rules target the current user and page.

* **Returns:** `Object|null`

### freeVisitsLeft

```javascript
Pelcro.paywall.freeVisitsLeft()
```

Calculates the number of free article views remaining in the current metering period.

* **Returns:** `Number|null`

### displayPaywall

```javascript
Pelcro.paywall.displayPaywall(dispatchEvent)
```

Determines whether the paywall should be displayed. Optionally dispatches `PelcroPaywallDisplayed` or `PelcroPaywallNotDisplayed`.

* **Returns:** `Boolean`

### displayMeterPaywall

```javascript
Pelcro.paywall.displayMeterPaywall()
```

Checks if a meter paywall should display. Increments the page view counter before checking.

* **Returns:** `Boolean`

### displayNewsletterPaywall

```javascript
Pelcro.paywall.displayNewsletterPaywall()
```

Checks if a newsletter signup paywall should display.

* **Returns:** `Boolean`

### isArticleRestricted

```javascript
Pelcro.paywall.isArticleRestricted()
```

Determines whether the current article is restricted from the user based on their subscription tags, entitlements, and paywall metatags.

* **Returns:** `Boolean`

***

***

## Subscription

Manages the full subscription lifecycle - creation, cancellation, renewal, and plan changes.

### create

```javascript
Pelcro.subscription.create(options, callback)
```

Creates a new subscription.

| Parameter                      | Type      | Required | Description                 |
| ------------------------------ | --------- | -------- | --------------------------- |
| options.plan\_id               | Number    | Yes      | Plan ID                     |
| options.source\_id             | Number    | No       | Payment source ID           |
| options.payment\_gateway       | String    | No       | `"stripe"` or `"braintree"` |
| options.gateway\_token         | String    | No       | Payment gateway token       |
| options.address\_id            | Number    | No       | Address ID                  |
| options.coupon\_code           | String    | No       | Coupon code                 |
| options.quantity               | Number    | No       | Seats (default: 1)          |
| options.gift\_recipient\_email | String    | No       | Gift recipient email        |
| options.campaign\_key          | String    | No       | Campaign key                |
| options.domains                | String\[] | No       | Allowed domains             |
| options.ip\_addresses          | String\[] | No       | Allowed IP addresses        |
| options.metadata               | Object    | No       | Custom metadata             |
| callback                       | Function  | Yes      | `(error, data)`             |

**Events fired:** `PelcroSubscriptionCreated`

### cancel

```javascript
Pelcro.subscription.cancel(options, callback)
```

Cancels a subscription.

| Parameter                | Type     | Required | Description         |
| ------------------------ | -------- | -------- | ------------------- |
| options.subscription\_id | Number   | Yes      | Subscription ID     |
| options.mode             | String   | No       | Cancellation mode   |
| options.reason           | String   | No       | Cancellation reason |
| callback                 | Function | Yes      | `(error, data)`     |

**Events fired:** `PelcroSubscriptionCanceled` (detail includes `canceledSubscriptionId`)

### reactivate

```javascript
Pelcro.subscription.reactivate(options, callback)
```

Reactivates a canceled subscription.

**Events fired:** `PelcroSubscriptionReactivated`

### renew

```javascript
Pelcro.subscription.renew(options, callback)
```

Renews an expired subscription.

| Parameter                | Type     | Required | Description       |
| ------------------------ | -------- | -------- | ----------------- |
| options.subscription\_id | Number   | Yes      | Subscription ID   |
| options.plan\_id         | Number   | Yes      | Plan ID           |
| options.source\_id       | Number   | No       | Payment source ID |
| options.payment\_gateway | String   | No       | Payment gateway   |
| options.gateway\_token   | String   | No       | Gateway token     |
| options.address\_id      | Number   | No       | Address ID        |
| options.coupon\_code     | String   | No       | Coupon code       |
| options.campaign\_key    | String   | No       | Campaign key      |
| callback                 | Function | Yes      | `(error, data)`   |

**Events fired:** `PelcroSubscriptionRenewed`

### renewGift

```javascript
Pelcro.subscription.renewGift(options, callback)
```

Renews a gift subscription.

> **Note:** This method does not fire `PelcroSubscriptionRenewed`. Only `renew()` dispatches that event.

### change

```javascript
Pelcro.subscription.change(options, callback)
```

Changes a subscription to a different plan.

| Parameter                | Type     | Required | Description     |
| ------------------------ | -------- | -------- | --------------- |
| options.subscription\_id | Number   | Yes      | Subscription ID |
| options.plan\_id         | Number   | Yes      | New plan ID     |
| options.address\_id      | Number   | No       | Address ID      |
| callback                 | Function | Yes      | `(error, data)` |

> **Note:** This method does not dispatch any events.

### update

```javascript
Pelcro.subscription.update(options, callback)
```

Updates subscription properties (suspension, domains, metadata).

| Parameter                           | Type           | Required | Description              |
| ----------------------------------- | -------------- | -------- | ------------------------ |
| options.subscription\_id            | Number         | Yes      | Subscription ID          |
| options.suspend                     | Boolean/Number | No       | Suspend the subscription |
| options.shipments\_suspended\_until | String         | No       | `"YYYY-MM-DD"`           |
| options.domains                     | String\[]      | No       | Allowed domains          |
| options.ip\_addresses               | String\[]      | No       | Allowed IP addresses     |
| options.metadata                    | Object         | No       | Custom metadata          |
| callback                            | Function       | Yes      | `(error, data)`          |

**Events fired:** `PelcroSubscriptionUpdated`

### redeemGift

```javascript
Pelcro.subscription.redeemGift(options, callback)
```

Redeems a gift subscription using a gift code.

**Events fired:** `PelcroGiftRedeemed`

### list

```javascript
Pelcro.subscription.list()
```

Returns the current user subscriptions.

* **Returns:** `Array`

### isSubscribedToSite

```javascript
Pelcro.subscription.isSubscribedToSite()
```

Checks if the user has any active non-donation subscription for the current site.

* **Returns:** `Boolean`

### isSubscribedToPlan

```javascript
Pelcro.subscription.isSubscribedToPlan(plan)
```

Checks if the user is subscribed to a specific plan.

* **Returns:** `Boolean`

### listMembers

```javascript
Pelcro.subscription.listMembers(options, callback)
```

Lists members of a group subscription.

### inviteMembers

```javascript
Pelcro.subscription.inviteMembers(options, callback)
```

Invites members to a group subscription by email.

### removeMember

```javascript
Pelcro.subscription.removeMember(options, callback)
```

Removes a member from a group subscription.

***

***

## Plan

Provides plan lookup by ID, IP address, or email domain.

### getById

```javascript
Pelcro.plan.getById(id)
```

Returns a plan by its ID from the cached product/plan data.

* **Returns:** `Object|null`

### getPlan

```javascript
Pelcro.plan.getPlan(options, callback)
```

Fetches a plan from the API by ID.

### getByIP

```javascript
Pelcro.plan.getByIP(callback)
```

Returns plans associated with the user IP address. Results are cached in session storage.

### getByEmail

```javascript
Pelcro.plan.getByEmail(options, callback)
```

Returns plans associated with a user email domain.

***

***

## Membership

Manages membership-based access control via IP or email domain.

### getByIP

```javascript
Pelcro.membership.getByIP(callback)
```

Returns memberships associated with the user IP address. Cached in session storage.

### getByEmail

```javascript
Pelcro.membership.getByEmail(options, callback)
```

Returns memberships associated with a user email domain.

### update

```javascript
Pelcro.membership.update(options, callback)
```

Updates a membership subscription member address.

| Parameter              | Type     | Required | Description     |
| ---------------------- | -------- | -------- | --------------- |
| options.membership\_id | Number   | Yes      | Membership ID   |
| options.address\_id    | Number   | Yes      | New address ID  |
| callback               | Function | Yes      | `(error, data)` |

***

***

## Payment Source (Legacy)

Manages legacy Stripe payment sources. For newer integrations, use Payment Method instead.

### create

```javascript
Pelcro.paymentSource.create(options, callback)
```

Creates a new payment source.

**Events fired:** `PelcroSourceCreated`

### update

```javascript
Pelcro.paymentSource.update(options, callback)
```

Updates a payment source expiration date.

**Events fired:** `PelcroSourceUpdated`

***

***

## Payment Method

Manages payment methods (cards, ACH, wallets) via the modern Payment Methods API.

### create

```javascript
Pelcro.paymentMethod.create(options, callback)
```

Creates a new payment method.

| Parameter           | Type     | Required | Description              |
| ------------------- | -------- | -------- | ------------------------ |
| options.auth\_token | String   | Yes      | Auth token               |
| options.token       | String   | Yes      | Tokenized payment method |
| options.gateway     | String   | No       | Payment gateway name     |
| callback            | Function | Yes      | `(error, data)`          |

**Events fired:** `PelcroPaymentMethodCreated`

### update

```javascript
Pelcro.paymentMethod.update(options, callback)
```

Updates a payment method.

**Events fired:** `PelcroPaymentMethodUpdated`

### list

```javascript
Pelcro.paymentMethod.list(options, callback)
```

Lists all payment methods for the current user.

### getPaymentMethod

```javascript
Pelcro.paymentMethod.getPaymentMethod(options, callback)
```

Retrieves a specific payment method by ID.

### deletePaymentMethod

```javascript
Pelcro.paymentMethod.deletePaymentMethod(options, callback)
```

Deletes a payment method.

**Events fired:** `PelcroPaymentMethodDeleted`

### verifyACH

```javascript
Pelcro.paymentMethod.verifyACH(options, callback)
```

Verifies an ACH bank account using a micro-deposit verification code.

**Events fired:** `PelcroPaymentMethodUpdated`

***

***

## Invoice

Provides access to user invoices and invoice payment.

### list

```javascript
Pelcro.invoice.list()
```

Returns the current user invoices from cached data.

* **Returns:** `Array`

### pay

```javascript
Pelcro.invoice.pay(options, callback)
```

Pays an outstanding invoice.

| Parameter                | Type     | Required | Description       |
| ------------------------ | -------- | -------- | ----------------- |
| options.invoice\_id      | Number   | Yes      | Invoice ID        |
| options.source\_id       | Number   | No       | Payment source ID |
| options.payment\_gateway | String   | No       | Payment gateway   |
| options.gateway\_token   | String   | No       | Gateway token     |
| callback                 | Function | Yes      | `(error, data)`   |

**Events fired:** `PelcroInvoicePaid`

***

***

## Coupon

Utility for extracting coupon codes from URLs.

### getFromUrl

```javascript
Pelcro.coupon.getFromUrl()
```

Extracts the `coupon_code` query parameter from the current page URL.

* **Returns:** `String|null`

```javascript
// URL: https://example.com/subscribe?coupon_code=SAVE20
const code = Pelcro.coupon.getFromUrl(); // "SAVE20"
```

***

***

## Ecommerce

Manages ecommerce products, SKUs, and order creation.

### list

```javascript
Pelcro.ecommerce.products.list(callback)
```

Fetches all ecommerce products for the current site.

**Events fired:** `PelcroEcommerceProductsLoaded`

### read

```javascript
Pelcro.ecommerce.products.read()
```

Returns the cached ecommerce products.

### getByProductId

```javascript
Pelcro.ecommerce.products.getByProductId(id)
```

Finds an ecommerce product by its ID.

### getBySkuId

```javascript
Pelcro.ecommerce.products.getBySkuId(skuId)
```

Finds a specific SKU by its ID across all cached products.

### getSkus

```javascript
Pelcro.ecommerce.products.getSkus()
```

Returns all SKUs, filtered by user currency if set.

### create

```javascript
Pelcro.ecommerce.order.create(options, callback)
```

Creates an ecommerce order.

| Parameter                | Type     | Required | Description          |
| ------------------------ | -------- | -------- | -------------------- |
| options.items            | Array    | Yes      | Array of order items |
| options.source\_id       | Number   | No       | Payment source ID    |
| options.address\_id      | Number   | No       | Shipping address ID  |
| options.coupon\_code     | String   | No       | Coupon code          |
| options.payment\_gateway | String   | No       | Payment gateway      |
| options.gateway\_token   | String   | No       | Gateway token        |
| callback                 | Function | Yes      | `(error, data)`      |

**Events fired:** `PelcroEcommerceOrderCreated`

### createSummary

```javascript
Pelcro.ecommerce.order.createSummary(options, callback)
```

Creates an order summary (price preview) without charging.

***

***

## Product

Provides access to the site subscription products and plans with filtering by currency, country, language, and entitlements.

### list

```javascript
Pelcro.product.list()
```

Returns products filtered by user currency, country, and page language.

### listByTarget

```javascript
Pelcro.product.listByTarget()
```

Returns products whose paywall targeting rules match the current user and page.

### getById

```javascript
Pelcro.product.getById(id)
```

Returns a product by its ID.

### getByEntitlements

```javascript
Pelcro.product.getByEntitlements(entitlements)
```

Returns products that match any of the specified entitlements.

### getByMatchingPageTags

```javascript
Pelcro.product.getByMatchingPageTags()
```

Returns products whose paywall tags match the current page Open Graph article tags.

***

***

## Order

Creates subscription order summaries for price previews.

### create

```javascript
Pelcro.order.create(options, callback)
```

Creates a subscription order summary (not an ecommerce order).

| Parameter             | Type     | Required | Description     |
| --------------------- | -------- | -------- | --------------- |
| options.plan\_id      | Number   | Yes      | Plan ID         |
| options.address\_id   | Number   | No       | Address ID      |
| options.coupon\_code  | String   | No       | Coupon code     |
| options.campaign\_key | String   | No       | Campaign key    |
| callback              | Function | Yes      | `(error, data)` |

***

***

## Address

Manages user shipping and billing addresses.

### list

```javascript
Pelcro.address.list()
```

Returns the current user addresses.

### create

```javascript
Pelcro.address.create(options, callback)
```

Creates a new address.

| Parameter           | Type     | Required | Description                 |
| ------------------- | -------- | -------- | --------------------------- |
| options.auth\_token | String   | Yes      | Auth token                  |
| options.type        | String   | Yes      | `"shipping"` or `"billing"` |
| options.line1       | String   | Yes      | Address line 1              |
| options.country     | String   | Yes      | Country code                |
| callback            | Function | Yes      | `(error, data)`             |

**Events fired:** `PelcroAddressCreated`

### update

```javascript
Pelcro.address.update(options, callback)
```

Updates an existing address.

**Events fired:** `PelcroAddressUpdated`

***

***

## Password

Handles password reset flows and password updates.

### forgot

```javascript
Pelcro.password.forgot(options, callback)
```

Sends a password reset email.

**Events fired:** `PelcroPasswordForgot`

### reset

```javascript
Pelcro.password.reset(options, callback)
```

Resets the user password using a reset token.

**Events fired:** `PelcroPasswordReset`

### update

```javascript
Pelcro.password.update(options, callback)
```

Updates the current user password. Automatically logs the user out after success.

**Events fired:** `PelcroPasswordUpdated`, then triggers `Pelcro.user.logout()`

***

***

## Newsletter

Manages newsletter subscriptions independently of user accounts.

### create

```javascript
Pelcro.newsletter.create(options, callback)
```

Creates a new newsletter subscription.

| Parameter     | Type     | Required | Description         |
| ------------- | -------- | -------- | ------------------- |
| options.email | String   | Yes      | Subscriber email    |
| options.lists | Array    | No       | Newsletter list IDs |
| callback      | Function | Yes      | `(error, data)`     |

**Events fired:** `PelcroNewsletterCreated`

### getByEmail

```javascript
Pelcro.newsletter.getByEmail(email, callback)
```

Gets newsletter subscription data for an email address.

### update

```javascript
Pelcro.newsletter.update(options, callback)
```

Updates an existing newsletter subscription.

### isSubscribedToNewsletter

```javascript
Pelcro.newsletter.isSubscribedToNewsletter()
```

Checks if the current browser has an active newsletter subscription (via cookie).

* **Returns:** `Boolean`

***

***

## Campaign

Retrieves campaign information for marketing and promotional flows.

### getByID

```javascript
Pelcro.campaign.getByID(options, callback)
```

Fetches a campaign by its numeric ID.

### getByKey

```javascript
Pelcro.campaign.getByKey(options, callback)
```

Fetches a campaign by its unique key.

***

***

## Insight

Tracks user analytics events via the Pelcro analytics pipeline.

### track

```javascript
Pelcro.insight.track(eventName, extraProperties)
```

Sends a custom analytics event.

| Parameter       | Type   | Required | Description                                       |
| --------------- | ------ | -------- | ------------------------------------------------- |
| eventName       | String | Yes      | Event name (e.g. `"Subscribed"`, `"Page Viewed"`) |
| extraProperties | Object | No       | Additional properties to include                  |

* **Returns:** `Promise<Boolean>` - Resolves to `true` on success.

```javascript
Pelcro.insight.track("Subscribed", { plan_id: 123, method: "sdk" });
```

The SDK automatically tracks certain events internally (subscriptions, newsletter signups, page views for authenticated users). Use this method for custom tracking.

***

***

***

## Integrations

Accessed via `window.Pelcro.integrations`.

### getToken

```javascript
Pelcro.integrations.disqus.getToken(callback)
```

Retrieves Disqus SSO authentication credentials for the current user. The user must be authenticated.

* **Callback:** `(error, response)`
  * `response.data.disqus_auth_key` - SSO auth key
  * `response.data.disqus_public_key` - Disqus public key

```javascript
Pelcro.integrations.disqus.getToken((error, response) => {
  if (error) {
    return console.log("error", error.message);
  }

  const { disqus_auth_key, disqus_public_key } = response.data;
  console.log("disqus_auth_key", disqus_auth_key);
  console.log("disqus_public_key", disqus_public_key);
});
```

# Sibling pages

* [Events](https://docs.pelcro.com/v2.4/docs/javascript-sdk-events.md)