Complex experiments such as the stellarator Wendelstein 7-X demand efficient experiment planning, operation and data evaluation. To assist the process organization at W7-X, a metadata framework has been implemented. It annotates a physics program with tags describing its intention, main parameters, boundary conditions, and evaluation results. The approach enables relevant metadata to be collected exactly where information is available and to forward it from experiment planning and execution to the related entry in the central W7-X Logbook. In consequence, these metadata offer possibilities for classifying, searching, filtering etc. both in the database of prepared programs and in the logbook of executed programs. Wherever possible, metadata are generated automatically. Starting from the program's parameters, the framework allows typical physics or technical quantities or any programmatically extractable information describing the programs intention to be extracted already while editing. During discharge preparation, metadata are retrieved from the related session planning documents and from the actual session environment. Supplementary tags can be added manually from an extendible tag catalog to categorize experiment programs or to provide metadata for not fully integrated diagnostics. All metadata are logged together with status and progress information during execution and are available within the program's log -where the metadata can be finally completed e.g. to manually qualify the program's success or by adding programmatically produced metadata using the logbook's programming interface.