Question

I have a boomerang plugin that adds some custom variables, and then calls sendBeacon(). I'd like its behavior to be slightly different if the variables will be attached to the first beacon vs. if sendBeacon() causes a second beacon to be sent.

It looks like I could subscribe to page_ready and set a flag when that event fires. Since page_ready also triggers the rt plugin to send a beacon, I can infer that calls before the flag is set will attach to the first beacon.

Alternatively, I could subscribe to before_beacon and set a flag or counter and make the same inference.

Are there any pros or cons to either approach?

Was it helpful?

Solution

Subscribe to the before_beacon event and set your flag there. page_ready itself may not result in a beacon because some plugins may not be ready to send yet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top