The tag property can be set through code or in the IDE.
If you want to keep track of components that are created programatically, it is probably easiest to set the tag property at the time the components are created. You can see some examples here.
That said, if you need to loop through some components and set their tags, your approach will differ depending on the setup of your form. You may need to resort to using numerical indexing and/or using type(DropDown)
to keep track of which type of component you are operating on.
If you have a specific example you can share, that would make it easier to provide more specific help.