I achieved the same result for about a dollar and a couple days of paying attention.
We hung a small bell on a string off of the doorknob. Every time we took the puppy out we would first hold its paw and boop the bell before opening the door.
After 2 or 3 weeks of persistent repetition on every excursion, our now nearly year-old pup has yet to have any accident in many months!
Though the one drawback is when puppy is bored, you’ll know it from the frequent non-potty related rings. Fair trade off I would think…