Make sure you’re creating the datagroup (class) definition in the GUI under iRules | Datagroups. There is a separate tab for datagroups next to the iRules tab. If your class is made up of strings, select a type of string.
The format you have above is how it would look in the bigip.conf file. If you want to add the class definition to the bigip.conf file, edit it with vi or pico and add the object definitions in and run ‘b load’ to load the new configuration to memory.