Send your own events with Varly.track

Count actions such as a newsletter signup or an add to cart, and use them as the goal of an A/B test.

In this article

Orders are the strongest goal, but a shop with few orders can wait months for a verdict. Actions that happen more often, such as adding a product to the cart or signing up for the newsletter, give an answer sooner. Varly already measures page visits and clicks. For anything else, your site sends its own event.

Use an event as a test goal

  1. Ask your developer to send the event (see For developers below), for example newsletter_signup.
  2. Open the test and go to Launch.
  3. Under What counts as a conversion, choose Custom event for the Primary goal, or click Add a secondary goal.
  4. Type the event name exactly as your site sends it. Capitals count: Signup and signup are different events.
  5. Launch the test as usual. See Launch, pause, resume and end a test.

A visitor counts as converted when the event arrives after their first visit to the test. Sending it twice for the same visitor still counts once.

Added to cart on Shopify

Choose Added to cart as a goal. On Shopify, Varly sends the event add_to_cart by itself when a visitor adds a product with the add-to-cart button of your theme. Most themes use the standard Shopify cart form, and then nothing else is needed.

Some themes and apps add products in another way, for example a quick-buy button from an app. Those additions are not counted unless your developer sends add_to_cart with Varly.track.

On other platforms, your developer sends add_to_cart when a product is added to the cart.

When events are not sent

Varly drops an event, without an error, when:

  • the visitor did not accept cookies in your cookie banner;
  • the page is under Never track these pages in Site settings (such as your checkout);
  • tracking is off for the site (Install → 3. Turn tracking on);
  • the snippet has not loaded yet.

Common problems

  • The goal stays at 0. Check that the name in the test matches the name in the code exactly. Then do the action yourself on your site, accept cookies first, and check again after a few minutes.
  • The plan says the goal is "estimated". Varly hasn't seen the event in visits to the test page in the last 4 weeks, so it plans with an estimate of 3%. The test still counts the event once it arrives.
  • Fewer events than in your own analytics. Varly only counts visitors who accepted cookies, and never counts visits from your own excluded devices or IP addresses.

For developers

Call window.Varly.track(name, properties) from your own code:

if (window.Varly) window.Varly.track('newsletter_signup', { form: 'footer' })
  • name: text, at most 64 characters. Spaces at the start and end are removed.
  • properties (optional): a flat object with at most 10 values. Values can be text (cut at 100 characters), numbers or true/false. Objects, lists and other values are left out. Don't send personal data such as names or email addresses.
  • At most 50 events per page view are kept, so a loop in your code can't flood your data.
  • The call never throws an error and never slows the page down. It does nothing until the snippet has loaded and the visitor has given consent, so check window.Varly first, as in the example.

The event is sent with the same batch as clicks and page views, so it can take a few seconds before it leaves the browser. Events sent just before the visitor leaves the page are still delivered.

Was this article helpful?

Still stuck? Email support@varly.ai and we'll help you out.

Related articles