Skip to main content

Advanced JavaScript tracking API

A guide for advanced users on tracking conversions with JavaScript objects.

P
Written by Podia Labs
Updated over a week ago

Podia makes it easy to track conversions with Google Analytics, Facebook Pixel, and Pinterest Tags, but it's possible to do more sophisticated tracking using our JavaScript objects 🤓

These objects can be accessed through custom code added to your Podia site. This feature is available on our Mover and Shaker plans. You can learn more about Podia's plans on our pricing page!

Before we begin, a quick heads up...

These settings require some technical knowledge and can be intimidating. Using this feature incorrectly could potentially break your Podia site. 💥😱

📋 Note: While we’re happy to help with any issues taking place on our end, we aren’t able to access your accounts with those other tools, which limits the support we can offer. We encourage reaching out directly to the third-party tools for help getting them working.

JavaScript Objects

Customer Object

Every page on your Podia site has access to a Podia.Customer object, which represents the currently logged-in customer.

Available attributes

  • id

  • email

  • first_name

  • last_name

  • stripe_id

  • created_at

Example object

{
    id: 7,
    email: "[email protected]",
    first_name: "James",
    last_name: "Bond",
    stripe_id: "cus_X007",
    created_at: 1518554863241
}

Notes

  • first_name and last_name will be null if the customer hasn't provided them.

  • created_at represents when the customer initially signed up as a UNIX timestamp (integer). If necessary, it can be used to construct a native Date object like so: var signupDate = new Date(Podia.Customer.created_at);

  • Podia.Customer will be null if there is no customer currently logged in. It's a good idea to first check for the existence of a customer before attempting to access attributes. For example:

if(Podia.Customer) {
  console.log(`Customer email is ${Podia.Customer.email}.`);
  console.log(`Signed up ${new Date(Podia.Customer.created_at)}.`);
} else {
  console.log('No customer logged-in.');
}

Conversion Object

A Podia.Conversion object is available after a customer purchases a course, product, or membership subscription (both free and paid). This object is only available on the thank-you pages after checkout, and will only appear once — the Podia.Conversion object disappears if the thank-you page is refreshed to prevent duplicate tracking.

Available attributes

  • customer

  • revenue_cents

  • revenue

  • currency

  • object

Notes

  • customer is a Podia.Customer as described above.

  • revenue_cents will be 0 for free products and membership plans.

  • revenue is a decimal (dollar and cents) representation of revenue.

  • currency is the ISO code of the currency revenue_cents is denominated in.

  • object is the product or subscription that was purchased, detailed below.

Available attributes for object

  • type The type of conversion that occurred, either "product" or "subscription". Note that "product" represents both digital downloads and online courses.

  • id The unique ID for the product or membership plan (i.e. SKU).

  • name The name of the product or membership plan that was purchased.

  • order_id The unique ID for this order or subscription (i.e. transaction ID).

Example product purchase

{
    customer: {
        id: 7,
        email: "[email protected]",
        first_name: "James",
        last_name: "Bond",
        stripe_id: "cus_X007",
        created_at: 1518554863241
    },    revenue_cents: 49500,
    revenue: 495.00,
    currency: 'USD',    object: {
      type: 'product',
      id: 12345,
      name: "Design For Developers",
      order_id: 90210
    },
}

Finishing up

We recommend that you disable any ad-blockers and use private browsing (incognito mode) when testing your custom JavaScript integration. And remember, the Podia.Conversion object is only available immediately following a conversion and disappears on the next page request.

Did this answer your question?