Tracking before page->go()

good morning everybody. i’m looking for a way to load a trackingpixel or telling bnomeis pageviewcounter a count before using the $page->go() function to redirect to another page. i’m pretty shure it’s easy like hell but i don’t get it to run. is there anyone who could help me out, please?

@bnomei’s pageview counter uses native lazy loading to only load the pixel when the user scrolls

The tracking image will be moved below the fold and trigger the counter with native lazy loading on first user scroll. Why? To avoid most of the bots.

So this won’t work with a redirect and you would have to use your own tracking pixel.

thats correct. i moved the pixel to the top of the page so there’s no need to scroll to activate the count.
my problem is, with the go-function included the pixel doesn’t even get rendered. i need some kind of delay before it goes on with the redirect. tried sleep() in several ways but i’m not a coder and yeah…now i’m here.

Yes, right, in fact since the page is never rendered when you use a redirect, a tracking pixel will be of no use, not even with a delay.

What you could do instead is use routes for these redirect pages that call the same code that the plugins does in its routes before you redirect from that route.

allright. tryin to head in that direction. thank you texnixe.

the counter image uses the time() to track the visit.

you could also call the increment any page you like by calling the singletons method

\Bnomei\PageViewCounter::singleton()->increment(
   $mypage->id(),
    time() // aka now
);

that is the same thing that would happen before rendering the 1x1 pixel image.

1 Like