Skip to content

Commit

Permalink
feat(Google Doc): call trackSidebarAdImpression on first render of GD…
Browse files Browse the repository at this point in the history
…ocAdvertText
  • Loading branch information
stevekaplan123 committed Mar 26, 2024
1 parent 2f56109 commit 2063be0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions static/js/Misc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Cookies from "js-cookie";
import {EditTextInfo} from "./BookPage";
import ReactMarkdown from 'react-markdown';
import TrackG4 from "./sefaria/trackG4";
import {trackSidebarAdClick, trackSidebarAdImpression} from "./Promotions";
const cookie = Sefaria._inBrowser ? $.cookie : Sefaria.util.cookie;

/**
Expand Down Expand Up @@ -61,7 +62,6 @@ const __filterChildrenByLanguage = (children, language) => {
let newChildren = chlArr.filter(x=> x.type == currLangComponent);
return newChildren;
};

const GDocAdvertText = () => {
return <InterfaceText>
<EnglishText> Add texts directly to your Google Docs with our <span id="newExtension">new extension</span>! <a href="https://sefaria.org/sheets/529099?origin=AddToSheetsPromo">Learn more</a></EnglishText>
Expand All @@ -74,19 +74,21 @@ const GDocAdvertBox = () => {
if (firstRender.current) {
firstRender.current = false;
if (!cookie(gdocInstalled)) { // on first render and "Install Now" has never been clicked before
gtag('event', 'promotion_shown', {loc: 'Resources Panel'});
trackSidebarAdImpression(gdocsCampaign);
}
}
})
const gdocsCampaign = {campaignId: "GDocs_Promo_AddToSheet"};
const gdocInstalled = 'gdoc_installed';
const handleInstall = () => {
cookie(gdocInstalled, JSON.stringify(1), {path: "/"});
trackSidebarAdClick(gdocsCampaign);
}
return !cookie(gdocInstalled) &&
<div className="gDocAdvertBox">
<GDocAdvertText/>
<div id="installNow"><a href={'https://workspace.google.com/marketplace/app/sefaria/849562338091?utm_source=SefariaOrg&utm_medium=SidebarAdButton&utm_campaign=AddToSheetPromotion&utm_content=InstallFromAddToSheet'}
onClick={handleInstall}><InterfaceText>Install Now</InterfaceText></a></div>
<GDocAdvertText/>
<div id="installNow"><a href={'https://workspace.google.com/marketplace/app/sefaria/849562338091?utm_source=SefariaOrg&utm_medium=SidebarAdButton&utm_campaign=AddToSheetPromotion&utm_content=InstallFromAddToSheet'}
onClick={handleInstall}><InterfaceText>Install Now</InterfaceText></a></div>
</div>;
}

Expand Down
2 changes: 1 addition & 1 deletion static/js/Promotions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,4 @@ const SidebarAd = React.memo(({ context, matchingAd }) => {
);
});

export { Promotions };
export { Promotions, trackSidebarAdImpression, trackSidebarAdClick };

0 comments on commit 2063be0

Please sign in to comment.