Data Settings

Tracking Events with Code #

For advanced tracking, you can use the ptengine.track method to monitor key user actions, such as:

  • Successful form submissions
  • Completed purchases
  • Clicks on important buttons

This method lets you track specific user interactions and even add extra details, like product information or customer behavior data.

How to Implement Event Tracking

1️⃣ Use the ptengine.track method to track events.

2️⃣ Embed this code inside any user action (e.g., checkout, form submission).

3️⃣ Customize event properties to collect more detailed insights.

📌 Example Code:

This example tracks a purchase event, including product details.

ptengine.track("check_out", {  //Event name,for example purchase、signup…
product_category: "Clothing",  //Event profile, for example sku, signup information…
product_pricing: "1293"
});

Learn More

Not familiar with Ptengine’s event definitions? [Check out this guide] to learn more about event tracking.

Example 1 : Collect users who register by clicking the Register button

document.getElementById('btnLogin').addEventListener('click', function (){
ptengine&&ptengine.track('signup');
});

Example 2: When there are two add-to cart buttons on the page, but we want to mark both two buttons as one event

try {
<script type="text/javascript">try {window.ptengine && window.ptengine.track("purchase");} catch (e) {console.error("Error tracking purchase:", e);}</script> opationRecord = [];
      function ptEventSend(eventName) {
          if (eventName && !opationRecord.includes(eventName)) {
              opationRecord.push(eventName);
              window.ptengine && window.ptengine.track(eventName);
          }
      }

      function addEventListenersToElements() {
          var addCartBottom = document.getElementById(add_cart_bottom);
          var addCart = document.getElementById(add_cart);

          if (addCartBottom) {
              addCartBottom.addEventListener(click, function() {
                  ptEventSend(add the products to cart);
              }, false);
          }

          if (addCart) {
              addCart.addEventListener(click, function() {
                  ptEventSend(add to cart from the sticky bar);
              }, false);
          }
      }

      addEventListenersToElements();

      var ptTimer = setInterval(addEventListenersToElements, 500);

  } catch (e) {}

Setting Up Personalized User Tracking #

What Does the Identify Code Do? #

The Identify Code helps recognize and track users, turning anonymous visitors into identified users. This allows you to:

  1. Track individual users across sessions for better insights.
  2. Collect key user details, such as:
    • Last Active Date
    • Registration Date
    • Total Sessions
    • Referring Domain on First Visit
    • Source URL on First Visit
  3. Create detailed user profiles for personalized content and marketing.

Where to Place the Identify Code #

We recommend adding the Identify Code on pages where users log in, sign up, or enter personal details, such as:

  • Login Page
  • Registration Page
  • Membership Signup Page

When a user logs in or registers, Ptengine links their information to their device, making it possible to track individual behavior and optimize their experience.

How the Identify Code Works #

Example Code:

This example assigns a unique ID (Uid) to a user and stores key details like name, email, and membership type.

Viewing and Exporting User Data #

Once users are identified, Ptengine binds user attributes to their unique ID (Uid). You can:

  • View user data inside the User Module.
  • Export user insights for analysis and marketing campaigns.

Was this article helpful?

  • Yes, great!
  • Not really

Thanks for your feedback.

  Sorry about that. Do you mind sharing how we can improve?

    Write your feedback here...