How-to build a link forwarder with tracking in IPFS

in #ipfs8 months ago (edited)

And this is all 100% privacy friendly!

I built a little forwarder yesterday to kyber.network's ETH token swap, here's how I did it.

Setup

How-to

You need to create a .html file via notepad, here's my example

<head>
<title>Decentralized Ethereum Swaps on IPFS</title>
<META HTTP-EQUIV=Refresh CONTENT="2; URL=https://widget.kyber.network/v0.7.5/?type=swap&mode=popup&lang=en&pinnedTokens=ETH_KNC_PBTC&defaultPair=ETH_KNC&callback=https%3A%2F%2Fkyberpay-sample.knstats.com%2Fcallback&paramForwarding=true&network=mainnet&commissionId=0x530922B450B77e365C4249A65C784CcFE770dd6A&theme=theme-emerald">
</head>

<script type="text/javascript">
  var _paq = window._paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//nfogix.com/";
    _paq.push(['setTrackerUrl', u+'api/track']);
    _paq.push(['setSiteId', '']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'js/nfogix.min.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
</body>

</html>

<META HTTP-EQUIV=Refresh CONTENT="2;

This part has the URL to forward to in it. Just copy and change URL=https://widget.kyber.network/v0.7.5/?type=swap&mode=popup&lang=en&pinnedTokens=ETH_KNC_PBTC&defaultPair=ETH_KNC&callback=https%3A%2F%2Fkyberpay-sample.knstats.com%2Fcallback&paramForwarding=true&network=mainnet&commissionId=0x530922B450B77e365C4249A65C784CcFE770dd6A&theme=theme-emerald to the URL you want to forward to.

script type="text/javascript">

This part is the https://nfogix.com/ tracking code. You find your tracking code in your dashboard

Save the file as name.html

Pinata

Now it's super easy. Go to pinata and upload your html file.

After upload is done, head to https://pinata.cloud/pinexplorer and there is the IPFS hash + Weblink to your forwarder.

image.png
Link: QmcztYTfoWs4viwGetKBMJCc9yejrTJTx3bisbHGAUYv82

So every time someone clicks your link, they open the IPFS .html, which has your nfogix tracking code. After 2 seconds, the website forwards to your set URL.

Example tracking

Cool to know

If you own a .ENS (Ethereum Domain) or a .CRYPTO (Unstoppabledomain) you can use the IPFS hash and link it to your domain!

Here's mine for dexcited.crypto

image.png



IPFS Based Forwarding: Click Here || Alternative: dexcited.crypto