Enable page view signals in the Connect web library

The page view signal captures when users view pages on your website. This is the easiest signal to implement and provides foundational tracking for user navigation patterns.

Reasons to enable:

  • Track navigation patterns across your site
  • Understand which pages and categories receive most traffic
  • Identify drop-off points in user journeys
  • Segment users based on content consumption

Availability: Premium and Ultimate


Implementation considerations

What constitutes a page view

A page view occurs when content is loaded or reloaded for the user. This typically includes:

  • Full page loads (traditional navigation)
  • Page reloads
  • Browser back/forward navigation to cached pages

For single-page applications, you may need to trigger signals manually when content changes significantly, even if the browser doesn't perform a full page load.

Data collection strategies

  • From URL - Capture the current page URL from the browser address bar (window.location.href). You can extract page category from structured URLs (for example, /clothing/shirts/ → category: "clothing").
  • From data layer - If your website has a data layer, extract URL and category information from there for more reliable data.
  • From page content - Scrape category information from page elements like breadcrumbs, navigation or meta tags.

URL handling

Consider these URL scenarios:

  • Query strings - Decide whether to include or strip query parameters.
  • Fragments - Handle hash fragments for single-page applications
  • Trailing slashes - Normalize URLs for consistent tracking

Configuration

Method

TLT.logSignal(signalObject)

Sends the signal to the Acoustic Connect endpoint as a JSON object. The Connect library must be initialized before calling this method.

Signal structure

Top-level fields

  • category: String - Valid value - Behavior.
  • description: String - Description of the signal
  • effect: String - Describes the effect of the signal on engagement. Valid values: negative, positive. Use positive for standard page views.
  • name: String - Name to differentiate this signal from others (for example, "Page view from website"). Max length - 256 chars.
  • signalType (required): String - Valid value - pageView.

Signal content

  • pageCategory: String - The category that the page belongs to (for example, "clothing", "electronics", "about"). Can be parsed from the URL or extracted from the data layer.
  • pageGroup: String - A grouping for related pages
  • url (required): String - The URL of the page the user has opened

Note:

  • If any required field is missing or invalid, the entire signal will be discarded.
  • Optional fields enhance the signal. They won't prevent processing if omitted or invalid.

Basic example

const signal = {
    // Required fields
    signalType: "pageView",
    category: "Behavior",
    name: "pageView from website",
    url: "https://example.com/clothing/shirts",
    effect: "positive",

    // Optional fields
    pageCategory: "clothing",
    pageGroup: "products",
    signalCustomAttributes: []
};

// Send the signal
TLT.logSignal(signal);

Complete implementation example

This example demonstrates multiple approaches to extracting page category:

// Check that the Connect library is present
if (window.TLT && window.TLT.isInitialized()) {
    const signal = {
        signalType: "pageView",
        category: "Behavior",
        name: "pageView generated by website",
        url: window.location.href.split("?")[0],
        pageCategory: "",
        pageGroup: "",
        effect: "positive"
    };

    // Method 1: Extract from URL path structure
    const pathSegments = window.location.pathname.split("/").filter((segment) => segment);
    if (pathSegments.length > 0) {
        signal.pageCategory = pathSegments[0];
    } else {
        signal.pageCategory = "home";
    }

    // Method 2: Override with data layer if available
    if (window.dataLayer && window.dataLayer.pageCategory) {
        signal.pageCategory = window.dataLayer.pageCategory;
    }

    // Method 3: Override with page-specific meta tag
    const categoryMeta = document.querySelector('meta[name="page-category"]');
    if (categoryMeta) {
        signal.pageCategory = categoryMeta.getAttribute("content");
    }

    // Method 4: Use breadcrumb navigation
    if (!signal.pageCategory || signal.pageCategory === "home") {
        const breadcrumb = document.querySelector(".breadcrumb li:nth-child(2)");
        if (breadcrumb) {
            signal.pageCategory = breadcrumb.innerText.toLowerCase().trim();
        }
    }

    // Handle special cases
    if (signal.url.includes("/search")) {
        signal.pageCategory = "search results";
    } else if (signal.url.includes("/cart") || signal.url.includes("/checkout")) {
        signal.pageCategory = "checkout";
    } else if (signal.url.includes("/account") || signal.url.includes("/profile")) {
        signal.pageCategory = "account";
    }

    // Optional: Log signal for debugging
    console.log("pageView signal:", JSON.stringify(signal, undefined, 2));

    // Send signal to Acoustic
    window.TLT.logSignal(signal);
}

Best practices

  1. Make sure the signal triggers consistently across all pages of your site.
  2. Normalize the URLs. Strip query parameters and fragments if they don't represent unique content.
  3. Standardize category names across your site (lowercase, no special characters).
  4. Handle special pages such as search results, checkout and error pages with specific category values.
  5. Test the signal on standard pages and after dynamic content loads.

Troubleshooting

Signal not firing on some pages?

  • Verify the Connect library loads and initializes on all pages.
  • Check that your signal code executes after library initialization.
  • Ensure no JavaScript errors prevent the signal code from running.
  • Test on static and dynamic pages.

URL not captured correctly?

  • Check if query parameters should be included or stripped.
  • Test with different URL formats (trailing slashes, multiple path segments).
  • Use window.location.href for full URL or window.location.pathname for path only.

Page category empty or incorrect?

  • Make sure URL structure matches your extraction logic.
  • Test fallback methods if primary extraction fails.
  • Check for typos in path segment indexes.
  • Consider using data layer as primary source if available.

Duplicate signals on single page load?

  • Check if signal code runs multiple times.
  • For single-page applications, ensure signals only fire once per route change.
  • Consider debouncing or adding flags to prevent duplicates.