Skip to main content

Advanced JavaScript tracking API

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

Written by Rodrigo

Podia makes it easy to track conversions with Google Analytics, Facebook Pixel, and Pinterest, 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. It's going to be marked as product for any of the product types on Podia - such as online courses, digital downloads, community plans, etc.

  • 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.

FAQs

Can I use Meta’s Conversions API with my Meta Pixel?

Yes.

If you’re sending events to Meta from your own server (using Meta’s Conversions API, Google Tag Manager, or a custom integration) and you’re also using Podia’s built-in Meta Pixel integration, Meta may receive the same event twice.

To prevent duplicate tracking, Meta uses an event ID to determine whether two events represent the same action.

You can learn more about how Meta deduplicates Pixel and Conversions API events in Meta’s documentation: https://developers.facebook.com/docs/marketing-api/conversions-api/deduplicate-pixel-and-server-events/

Podia automatically includes an event ID with the Meta Pixel events it sends.

If you’re sending the same events to Meta through your own server-side setup, you can use that same ID as the event_id in your Conversions API event to help Meta deduplicate the events.

How do I access the event ID?

You can access the event ID using Podia’s JavaScript tracking events.

Purchase events

document.addEventListener("podia:checkout:purchase", (event) => {   const eventId = event.detail.id; });

The same purchase ID is also available on the thank-you page as:

Podia.Conversion.object.order_id

Add to cart events

document.addEventListener("podia:checkout:start", (event) => {   const eventId = event.detail.id; });

Customer signups (CompleteRegistration)

document.addEventListener("podia:customer:signup", (event) => {   const eventId = event.detail.customer.id; });

The customer’s ID is also available as:

Podia.Customer.id

Important

For purchase events, use Podia.Conversion.object.order_id (or event.detail.id from the podia:checkout:purchase event) as your Meta event_id.

Do not use Podia.Conversion.object.id, as that value refers to the product ID rather than the purchase itself.

Do I need to do anything if I’m only using Podia’s Meta Pixel?

No.

If you’re only using Podia’s built-in Meta Pixel integration, no action is required. Your pixel will continue working as normal.

This information is only relevant if you’re also sending the same events to Meta through your own server-side tracking setup and want Meta to deduplicate those events.

Did this answer your question?