Have you checked that the following indeed returns the Site-ID (id of the root ancestor) of the current page?
<f:function xmlns:f="http://www.composite.net/ns/function/1.0" name="Composite.Pages.GetPageId">
<f:param name="SitemapScope" value="Level1" />
</f:function>
I've before had trouble with it and would use a filter that filters by Ancestor where ParentId equals Guid.Empty. That way you're sure to get the root ancestor of your current page.