Measure the carpet edge with a tape measure to determine the needed length of the z bar. Cut the z bar with a hacksaw if necessary to make it fit into the space.
Pull the carpet past the z bar location, allowing for 1 inch of excess carpet to attach into the z bar.
Attach the z bar to the subfloor by hammering 3/4-inch nails into the subfloor. Use appropriate nails for your subfloor; nails have separate ratings for concrete and wood.
Fold the excess carpet underneath the larger carpet piece. Place the fold carefully into the open z bar.
Hammer down the z bar onto the folded carpet with a rubber mallet. Hammer lightly to not over-bend the z bar onto the carpet.