Auto sort host via location

Good Day,

Is it possible to auto sort the hosts that is registered in katello to the correct location? For example:

test.com should go to location test, dev.com should go to location dev.

I have already setup the location and the domains in foreman but think I am missing something?

In the location the domain is included of test.com