While you can add your hotel number at check-in, most hotel programs do not provide rewards or benefits to online travel agency (consolidator) bookings. There is some inconsistency because most hotel are franchised, and the operator may choose to provides benefits when not required, but if you book through a credit card portal you cannot plan on it.
Airlines do provide rewards and benefits, because the economics of their relationship with agencies is fundamentally different.