Hello and welcome to our forums,
That is indeed the correct way to achieve this.
Regarding the component, you should choose a component that is always installed so the env variable will always be added.
If you are not familiar with what a component is, I would suggest reading the following article from Microsoft:
Windows Installer Components
Hope this helps!
Best regards,
Catalin