Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Link tracking and Lightboxes #2

Open
patrickd- opened this issue Feb 5, 2014 · 0 comments
Open

Problem with Link tracking and Lightboxes #2

patrickd- opened this issue Feb 5, 2014 · 0 comments

Comments

@patrickd-
Copy link

When using Lightboxes with the KISSmetrics -> General tracking -> Links in posts/pages setting active I'm experiencing the following issue:
The Lightbox opens for a second then it redirects me to the URL of the actual Image.

This is caused by the "trackClickOnOutboundLink" event handler which is attached to all links within the post/page when the setting is active.

KM.trackClickOnOutboundLink = function (a, b, c) {
        KM.e$(a, function (a) {
            KM.ev(a, "click", function (a) {
                try {
                    KM.record(b, c)
                } catch (d) {}
                for (var f = KM.sre(a); f && (!f.href || "a" != f.nodeName.toLowerCase());) f = f.parentNode;
                f && (!f.target && !a.shiftKey && !a.altKey && !a.ctrlKey && !a.metaKey) && (KM.pdft(a), setTimeout(function () {
                    document.location = f.href // <---- redirection to the actual image
                }, 250))
            })
        })
    };

This event handler logs the click and redirects to the actual image location.

This bypasses the event handler of the lightbox which uses e.preventDefault() to prevent the click on the image to redirect to the actual image location.

The wordpress plugin should not attach this event to lightbox'd links.

I spend several hours on finding a way for bypassing this problem but the fact that the script uses setTimeout(..., 1) to add non-blocking script tags made it nearly impossible to find a reliable workaround.

While I've never developed with Wordpress (I'm coming from Drupal/node.js) I can guess that this problem might be quite hard to solve even when modifying the plugin.
I wanted to leave a report with my experience here anyway.

For now we ended up disabling the Setting in the kissmetrics module options.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant