With respect to merchandise sold at a museum gift shop, IRS rules that where the primary purpose is to further the organization's exempt purpose, the sale is considered related thus not taxable. It is only where the primary purpose is to generate income that the sale is taxable.
IRS has taken the position that an art museum's gift shop sales of interpretive teaching items with artistic themes furthered the museum's educational purpose. Thus, items that develop artistic ability were considered substantially related to the museum's educational purpose. Also, items clearly for the convenience of the patrons, such as food or beverage are excludible from UBI.