How to integrate journy.io in an ecommerce webshop

Embed the snippet on each page

The snippet can be found in business settings, then click View tracking snippet on the correct domain.

The JS code snippet looks like:

<script src="XXX/tracker.js" async></script>
<script>
window.journy=window.journy||function(_,n,o){window.__journy_queue__||(window.__journy_queue__=[]),window.__journy_queue__.push({command:_,args:n,date:Date.now(),callback:o})};
journy("init", { trackerId: "XXX", domain: "XXX" });
journy("pageview");
</script>


Preferably in the head but at the end of body is also fine.

If you have a cookies popup, don't add snippet until user has accepted GDPR.

- journy("init", {...}) will initiate the tracking code
- journy("pageview") will send a page view for the current page

⚠️ You can only call journy(...) after the snippet (window.journy = ...), otherwise JavaScript will complain about calling an undefined function.

Link activity to email address and trigger event on checkout

A visitor will often be redirect to a thank you page after placing an order.

On this thank you page, generate the following JavaScript code as part of the page HTML:

<?php
$emailAddress = "fetch from session or pass email to thank page using GET parameter e.g. /thanks?email=<urlencoded email>";
if ($emailAddress) {
echo "<script>journy('identify', { email: {json_encode($emailAddress)} })</script>";
}
echo "<script>journy('event', { tag: 'checkout' })</script>";


json_encode("[email protected].io") will return "[email protected].io"

This is needed to avoid string escaping. If the email address is validated on checkout, you can do:

php
<?php
echo "<script>journy('identify', { email: '{$emailAddress}' })</script>";


You can also combine them in a single <script> tag.
Was this article helpful?
Cancel
Thank you!