your LBS should have a little hardware kit

that is sold with the flags. it's a 6" metal piece with points to attach to screws on your bike. you might have to customize it a little & possibly user a zip tie or two. lacking that, I one time used a curtain rod holder so I would have a kind of "cup" at the bottom.

I used flag when I started commuting

cuz I was used to flags for the family when we started riding with the kids when they were small. we were pretty cute. you could see us coming a mile away
I prefer the 1 piece flags but lots of them come in segments
https://www.amazon.com/Diamondback-S...1N4YHHJPNXQR0E