Widget and SDK
The widget
One tag, no code. Place an empty element where the offer should go.
<div data-tryme-offer data-placement="product_page"></div>
<script async src="https://tryme.com/assets/widget.js" data-merchant="your-slug"></script>
It renders into a shadow root, so your styles cannot break it and ours cannot leak into your page. If anything fails, it renders nothing: a broken card on your storefront would be worse than no card.
The SDK
Same decision, your markup.
const tryme = new TryMe({ merchant: 'your-slug' });
const offer = await tryme.decide({ campaignType: 'product_page', cartValueCents: 4200 });
if (offer) {
render(offer.copy);
link.href = tryme.claimUrl(offer);
}
tryme.track({ type: 'behavior.cart_added', payload: { productId: 'prd_123' } });
Callbacks
onOffer, onNoOffer and onError. Every method resolves rather than throwing: an exception escaping our script into your page could take your own scripts down with it.
What it will not do
claimUrl() returns a link rather than posting a claim. Claiming takes a name and an address, and this script does not go between a shopper and their personal details. The claim page is server rendered and works without JavaScript.