Hello! I’m trying to check on a reader’s membership tier in order to write something to our analytics tool.
I got this code from somewhere via search (silly me that I didn’t write down the source):
{{#match @member.tier.slug “=” "patron”}}
I was able to find all the slugs at ghost/api/admin/tiers/. But, a few of them were somewhat bizarre, such as the slug for the Free tier being 61f572239dd512162d094521. (!)
So, I tried @member.tier.name instead, but it doesn’t seem to be working. So, two questions:
- Is there an attribute for member.tier of “name”?
- Should the #match @member.tier.slug work?
Thanks!
FWIW – I was trying to track page views by the membership tier of the viewer. I wasn’t able to get the code with membership.tier.slug to work, so I fell back to this:
{{!-- Code to log type of visitor to Clicky --}}
{{#if @member.paid}}
<script type="text/javascript">
var clicky_custom = {};
clicky_custom.visitor = { "type": "Paid" };
</script>
{{else if @member}}
<script type="text/javascript">
var clicky_custom = {};
clicky_custom.visitor = { "type": "Free" };
</script>
{{else}}
<script type="text/javascript">
var clicky_custom = {};
clicky_custom.visitor = { "type": "Guest" };
</script>
{{/if}}
Now I can at least see which stories get read by which type of member.
A member might have multiple subscriptions. So you could do @member.subscriptions.[0].tier.name, or foreach over @member.subscriptions and write out tier.name for each.
Thanks! I had not realized that “tiers” is an array. Your solution makes perfect sense.
After pondering, though, I decided that breaking it down to the tier level was more granular than I actually needed. So, I’m happy for now with the three levels. Thanks for your help!
PS – This is a good example of the flexibility of the Clicky analytics tool, which I’ve been using and very happy with for years and years. More here: https://clicky.com