How to connect events from Google Analytics?

How does it work?

If you have already set up custom events in your Google Analytics account, you can easily use them with LiveSession. You can configure LiveSession callback to collect data every time the GA tracker sends a custom event.

Edit the code below according to your needs to start tracking GA custom events.

Custom Events are available via JS API. Learn how to use it.

How can I install this integration?

To install integration, edit your tracking ID (UA-XXXXXXXXX-X) and add the code after initializing Google Analytics and LiveSession.
<script>
    window.ga =
    window.ga ||
    function () {
        (ga.q = ga.q || []).push(arguments);
    };
    ga.l = +new Date();
    ga("create", "UA-XXXXXXXXX-X", "auto");
    ga("send", "pageview");
    ga(function (tracker) {
    var originalSendHitTask = tracker.get("sendHitTask");
    tracker.set("sendHitTask", function (model) {
        originalSendHitTask(model);
        const eventType = tracker.get("eventCategory");
        if (window.__ls) {
        window.__ls("track", eventType, {
            category: eventType,
            action: tracker.get("eventAction"),
        });
        }
    });
});
</script>

Didn’t find an answer?

Try using the search engine or just contact us

[email protected]Chat with us

Start using LiveSession for free now.

Free 14-day trial

No credit card required

Easy setup