Usually AJO by default will add the encrypted pid and payload in the URL parameter which will help to identify the profile. If you can share how you're personalizing in the template would be good to guide you further. Take a look at this page,
https://experienceleague.adobe.com/en/docs/journey-optim...