Seting up custom dimensions when users subscribe

Hi there,

We need to setup custom dimensions for when users subscribe to membership as follows:

Quarterly (xamount$), send custom dimension with value = Quarterly

ga(‘set’, ‘dimension1’, ‘Quarterly’:wink:; // if user successfully paid plan “QUARTERLY MEMBERSHIP”

Year (xamount$), send custom dimension with value = Yearly

ga(‘set’ ‘dimension1’ ‘Yearly’:wink:; // if user successfully paid plan “ONE YEAR MEMBERSHIP”

Can you please provide us with snippet for creating a custom variable in a conditional statement which hooks to action (user purchased x membership)? So something like this

If user purchase x membership return variable.

Thanks for your support in advance