Contact adhesive.
Roll or spray it on each surface, let it dry to where it doesn’t come off on your fingers when you touch it, (the carpet may need two coats if it doesn’t have a rubber backing, as it tends to soak in), then adhere together. But be careful on placement, once they touch they do not come apart without force.
3M makes very good spray adhesive in a few strengths, like Super 77 and High Strength 90.
Dap makes very good roll on adhesive in their Weldwood name.