Browser SDK: Switching from June to Accoil

If you’ve been using June's browser SDK to track user events, this guide will help you migrate your implementation to Accoil’s lightweight JavaScript tracker.

June’s SDK is based on an older version of Segment’s Analytics Next library. While Accoil shares many of the same concepts (track, identify, group), there are some important differences in naming, setup, and parameters. This guide walks you through what to change.


1. Replace the June Snippet

🧩 June's Original Setup

June’s script loads via:

<script>
  window.analytics = {};
  function juneify(writeKey) {
    window.analytics._writeKey = writeKey;
    var script = document.createElement('script');
    script.type = 'application/javascript';
    script.onload = function () {
      window.analytics.page();
    };
    script.src = 'https://unpkg.com/@june-so/analytics-next/dist/umd/standalone.js';
    var first = document.getElementsByTagName('script')[0];
    first.parentNode.insertBefore(script, first);
  }
  juneify('YOUR_WRITE_KEY');
</script>

✅ Replace with Accoil’s tracker.js

Accoil uses a custom tracker.js with no dependencies. Add the following snippet to your top-level template:

<script type="text/javascript">
(function() {
  var accoil = window.accoil = window.accoil || {q: []};
  var calls = ['load', 'identify', 'group', 'track'];
  for (var i = 0; i < calls.length; i++) (function(call) {
    accoil[call] = function() { accoil.q.push([call, arguments]); };
  })(calls[i]);
  var s = document.createElement('script'); s.src = 'https://cdn.accoil.com/tracker.js'; s.async = true;
  var f = document.getElementsByTagName('script')[0]; f.parentNode.insertBefore(s, f);
})();
</script>

<script type="text/javascript">
  accoil.load("YOUR_ACCOIL_API_KEY");
</script>

Note: Accoil’s global object is window.accoil, not window.analytics.


2. Update Method Calls

You’ll need to rename all analytics. calls to accoil. equivalents.

track

June:

analytics.track('Article Completed', {
  title: 'How to Create a Tracking Plan',
  course: 'Intro to Analytics'
});

Accoil:

accoil.track('Article Completed');
🟡

Accoil currently supports only the event name in .track() calls.

Additional properties (like title or course) are ignored.
We recommend naming events clearly and specifically, e.g. "Page Viewed: Pricing" or "Feature: Export Clicked".


🙋‍♂️ identify

June:

analytics.identify('user_123', {
  email: '[email protected]',
  name: 'Jane'
});

Accoil:

accoil.identify('user_123', {
  email: '[email protected]',
  name: 'Jane'
});

Works the same. Trait properties are supported.


🏢 group

June:

analytics.group('org_456', {
  name: 'Acme Inc',
  industry: 'Ecommerce'
});

Accoil:

accoil.group('org_456', {
  name: 'Acme Inc',
  industry: 'Ecommerce'
});

No changes needed. Used for account-level grouping.


📄 Replacing analytics.page(...)

June includes a .page() method, and automatically fires a page view when the SDK loads.

Accoil doesn’t use .page(), but you can easily track page views like this:

accoil.track(`Page Viewed: ${document.title}`);
📘

You don’t need to pass url, referrer, or additional properties — just track a clearly named event like "Page Viewed: Pricing" or "Page Viewed: Dashboard".


3. What to Remove or Skip

FeatureJuneAccoil Status
.page() methodSupportedReplace with .track()
.track() with propertiesSupported🔸 Properties ignored (for now)
options argumentSupported❌ Not supported
callback argumentSupported❌ Not supported

If you’re using options (e.g., destinations) or callbacks in your June implementation, you can safely remove those.


4. Final Implementation Example

<script type="text/javascript">
(function() {
  var accoil = window.accoil = window.accoil || {q: []};
  var calls = ['load', 'identify', 'group', 'track'];
  for (var i = 0; i < calls.length; i++) (function(call) {
    accoil[call] = function() { accoil.q.push([call, arguments]); };
  })(calls[i]);
  var s = document.createElement('script'); s.src = 'https://cdn.accoil.com/tracker.js'; s.async = true;
  var f = document.getElementsByTagName('script')[0]; f.parentNode.insertBefore(s, f);
})();
</script>

<script type="text/javascript">
  accoil.load("YOUR_API_KEY");
  accoil.identify("user_123", { email: "[email protected]" });
  accoil.group("org_456", { name: "Acme Inc" });
  accoil.track("Page Viewed: Dashboard");
</script>

Need Help Migrating?

We're happy to work with you directly to support a smooth switch from June.

📩 Email [email protected] or chat with us in Slack.