Above. Your links are urethane based foam and will stick to whatever it touches and hard to remove. As mentioned, will ruin the carpet.
Above foam, in past, was almost no good in that it was very weak kind of foam. But I thought good for your application.
Housedesigner idea is good although the gap may be too little. You can also use string or such and tap into the gap.
Using a long piece of thin metal. There are joint compound knife 12" and longer. Even heavy enough ruler will work. Press the carpet away to reveal the gap and use whatever you like. With capet swept away, I think caulk could work very well. If you get some caulk on the knife, wipe away, each time. These are what pros do.:smile: