Another approach would be to set a property in some common ec adp component and then pass that on to the master template (unless I'm misunderstanding what you're attempting to do). I'm not at all familiar with the ec package, but a quick look at the www/index page indicates that a toolbar component is <include>ed. I'm making the assumption that the toolbar is common throughout all ec pages (granted, it's a long stretch).
If the toolbar is included in every ec page, you could place <property name="is_in_ecommerce_p">true</property> in toolbar.adp and check for it in the master template like:
<if @is_in_ecommerce_p@ defined>