Reputation: 10857
If you look at the Google Analytics web components, you can see that there is a tag, google-analytics-view-selector, that will automatically create a view control for selecting Analytics properties. But I want access to that data via JS. In other words, how would one get the IDs if they wanted their own control for picking a property? I don't seem to see a property I can hit to fetch this.
Upvotes: 1
Views: 1414
Reputation: 24109
This works for me: http://jsbin.com/jojubezu/2/edit
The element exposed .views
, .accounts
, and .properties
that you should be able to use to constructor your own picker.
<style>
google-analytics-view-selector {
display: none;
}
</style>
<google-signin ...></google-signin>
<google-analytics-view-selector
on-analytics-dashboard-control-change="{{hasIds}}">
</google-analytics-view-selector>
</template>
<script>
Polymer('my-element', {
hasIds: function(e, detail, sender) {
console.log(sender.accounts, sender.views, sender.properties)
}
});
</script>
Upvotes: 3