I use XP in my current town-to-dungeon campaign. You earn it by overcoming challenges during the session. After the session, you can earn bonus XP for essentially talking about the notable events of that session. These bonus XP award resolving and creating new character ties, surviving the delve while having been dying at least once, defeating a notable monster, overcoming a challenge with words, learning something new and important about the world, and doing at least one heroic thing that people in town will talk about for days. So here I'm rewarding particular things on top of getting as many challenges done in the session as possible. It works well for keeping the players focused on what I intend to highlight in this game. You gain no XP if you're not at the session. You can level up at the end of a short or long rest if you have the requisite amount of XP.
Notably, all PCs start at 1st level regardless of what the average party level is. So if you join the game for the first time or bring in another PC (either because your other one died or you want to level up your background character), you start at 1st level. Many sessions see PCs of disparate levels and tiers. I found this works just fine - lower level PCs end up contributing well and leveling up very quickly. In the session before last, a 1st-level character played by [MENTION=6801984]Demorgus[/MENTION] went to 4th level in one session. [MENTION=6801813]Valmarius[/MENTION] is the highest-level PC at 6th level.
I have found that earning XP is a focus of the players during play. But that's okay! I tied their rewards to things I want them to do and, not surprisingly, they do it. This means the game is very well-paced and the PCs are always interacting with each other and examining their relationships, taking heroic risks, and exploring. Pretty much the essence of the town-to-dungeon experience if you ask me.