• OurPcGeek
  • Posts
  • How to Track Time Between Events in Adobe Analytics

How to Track Time Between Events in Adobe Analytics

Mastering Time Tracking Between Events in Adobe Analytics: A Step-by-Step Guide to Custom Solutions and Plugin Alternatives

Tracking the time between events is a powerful way to understand user behavior and optimize digital experiences. Adobe Analytics provides tools to capture and analyze this data, and with a bit of customization, you can measure the time elapsed between two events. In this guide, we’ll explore how to use the getTimeBetweenEvents plugin and provide an alternative custom solution.

1. What Is the getTimeBetweenEvents Plugin?

The getTimeBetweenEvents plugin is an Adobe Analytics add-on designed to calculate the time elapsed between two different events on your site or app. This tool is particularly useful for tracking metrics like:

  • Time spent on a page or feature.

  • Time between key user actions, such as adding an item to a cart and completing checkout.

  • Time lag between interacting with different sections of your website.

However, this plugin is not free. To access it, you’ll need to engage with Adobe Consulting Services.

2. Can’t Use Adobe Consulting? Build Your Own Solution!

If collaborating with Adobe Consulting is not an option, don’t worry. You can create a custom implementation to achieve similar results. Here’s a simple way to measure the time between two events.

3. Step-by-Step Guide to Building a Custom Solution

Here’s how you can track the time between two events using cookies:

  1. Set a Cookie When the First Event Fires

    • Use JavaScript to create a cookie that records the current timestamp when the first event (Event 1) is triggered.

    document.cookie = "eventTime=" + new Date().getTime() + "; path=/";
    

  2. Capture the Timestamp for the Second Event

    • When the second event (Event 2) is triggered, read the timestamp stored in the cookie.

    function getCookieValue(cookieName) {
        const cookies = document.cookie.split(';');
        for (let i = 0; i < cookies.length; i++) {
            const cookie = cookies[i].trim();
            if (cookie.startsWith(cookieName + "=")) {
                return cookie.substring(cookieName.length + 1);
            }
        }
        return null;
    }
    const t1 = parseInt(getCookieValue("eventTime"), 10);
    const t2 = new Date().getTime();
    

  3. Calculate the Time Difference

    • Subtract t1 from t2 to determine the time elapsed between the two events.

    const timeDifferenceInSeconds = (t2 - t1) / 1000;
    console.log("Time elapsed:", timeDifferenceInSeconds, "seconds");
    

  4. Send the Data to Adobe Analytics

    • Populate an Adobe Analytics variable (eVar or prop) with the time difference.

    s.eVarX = timeDifferenceInSeconds; // Replace eVarX with your variable
    s.t(); // Send the data to Adobe Analytics
    

4. Why This Matters

Tracking time between events can uncover critical insights:

  • Optimize Funnels: Identify where users spend too much time and streamline processes.

  • Improve User Experience: Measure engagement and refine content or features.

  • Understand User Intent: Determine how quickly users act on triggers like promotions or calls to action.

5. Best Practices for Time Tracking in Adobe Analytics

  • Use Unique Event Names: Avoid ambiguity by clearly defining the events you’re measuring.

  • Test Your Implementation: Verify accuracy across devices and browsers.

  • Comply with Privacy Regulations: Ensure compliance with GDPR, CCPA, and other privacy laws when using cookies.

By following this guide, you’ll have the tools to measure time between events effectively, even without the getTimeBetweenEvents plugin. Whether you leverage Adobe’s resources or go the custom route, you’ll gain valuable insights to drive business decisions.

Want more guides like this? Subscribe to our blog for expert Adobe Analytics tips and tricks!

Reply

or to participate.