send ga event for tag follow/unfollow
This commit is contained in:
parent
24cfe53165
commit
e503988fdc
3 changed files with 25 additions and 1 deletions
|
@ -14,6 +14,7 @@ type Analytics = {
|
|||
toggle: (boolean, ?boolean) => void,
|
||||
apiLogView: (string, string, string, ?number, ?() => void) => void,
|
||||
apiLogPublish: () => void,
|
||||
tagFollowEvent: (string, boolean, string) => void,
|
||||
};
|
||||
|
||||
let analyticsEnabled: boolean = true;
|
||||
|
@ -78,6 +79,16 @@ const analytics: Analytics = {
|
|||
Lbryio.call('feedback', 'search', { query, vote });
|
||||
}
|
||||
},
|
||||
tagFollowEvent: (tag, following, location) => {
|
||||
console.log('yep');
|
||||
if (analyticsEnabled) {
|
||||
ReactGA.event({
|
||||
category: 'Tag',
|
||||
action: following ? 'follow' : 'unfollow',
|
||||
value: tag,
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// Initialize google analytics
|
||||
|
|
|
@ -6,6 +6,7 @@ import Tag from 'component/tag';
|
|||
import TagsSearch from 'component/tagsSearch';
|
||||
import usePersistedState from 'util/use-persisted-state';
|
||||
import { useTransition, animated } from 'react-spring';
|
||||
import analytics from 'analytics';
|
||||
|
||||
type Props = {
|
||||
showClose: boolean,
|
||||
|
@ -56,6 +57,10 @@ export default function TagSelect(props: Props) {
|
|||
onRemove(tag);
|
||||
} else {
|
||||
doToggleTagFollow(tag.name);
|
||||
|
||||
const wasFollowing = followedTags.map(tag => tag.name).includes(tag.name);
|
||||
const nowFollowing = !wasFollowing;
|
||||
analytics.tagFollowEvent(tag.name, nowFollowing, 'tag-select');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import Page from 'component/page';
|
|||
import ClaimListDiscover from 'component/claimListDiscover';
|
||||
import Button from 'component/button';
|
||||
import useHover from 'util/use-hover';
|
||||
import analytics from 'analytics';
|
||||
|
||||
type Props = {
|
||||
location: { search: string },
|
||||
|
@ -33,11 +34,18 @@ function TagsPage(props: Props) {
|
|||
label = __('Unfollow');
|
||||
}
|
||||
|
||||
function handleFollowClick() {
|
||||
doToggleTagFollow(tag);
|
||||
|
||||
const nowFollowing = !isFollowing;
|
||||
analytics.tagFollowEvent(tag, nowFollowing, 'tag-page');
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<ClaimListDiscover
|
||||
tags={tags}
|
||||
meta={<Button ref={buttonRef} button="link" onClick={() => doToggleTagFollow(tag)} label={label} />}
|
||||
meta={<Button ref={buttonRef} button="link" onClick={handleFollowClick} label={label} />}
|
||||
/>
|
||||
</Page>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue