If we have a domain structure as 'example.test.com' and the main domain is 'test.com', we have in AAM built the trait as h_referer contains "test.com", would that capture 'example.test.com' data as well?
Yes, as long as you are using "contains" this trait will catch domain and sub domain both, as that's a substring match. Whereas, "==" is used for exact match.