Custom metric for page views

  • 9 December 2022
  • 4 replies

Badge +3

I'm trying to use the Klaviyo API to add custom metric when a particular page is viewed. I have followed the instructions from the klaviyo post here:

but the custom metric isn't being counted.

The reason we need this is to determine which users have completed checkout for an abandoned cart flow. The default Klaviyo flow won't work with our application because some payments are not done immediately. For example interac e-transfers, our customers will still receive an abandoned cart email after they have successfully checked out.

If we can create a metric on users who have or have not visited our Woocomerce "thank you" page we can accurately target them with an abandoned cart flow.

We could add a filter to the flow to make sure only those who didn't visit that thank you page in the last few hours would be targeted.

There's a section in the tutorial that recommends using a UTM parameter to test the email address. I don't quite understand if your saying every URL would need this UTM parameter to track views. 


Best answer by RedPhive 13 December 2022, 00:27

View original

4 replies

Userlevel 7
Badge +36

Hi @RedPhive and welcome back to the Community!


First off, may I ask how you’re testing the custom metric? One important thing to note is that the metric will only be tracked for customers that have been previously cookied. So if you’re testing from a browser where you haven’t entered your email or been captured by your store in another way, the testing would fail. Likewise, if customers visit the site and haven’t been cookied, they won’t appear either. 


That’s also what is being referred to in the Help Center - the point of appending the UTM parameter to the URL for testing is to simulate a previously cookied account, so that you can test from your own end. It’s not something that has to be considered for external visitors, since they will either be cookied previously or not - it’s just for testing. 


If you use the UTM parameter to test and you’re still not seeing the metric in your Klaviyo account, then that probably means that the snippet was not properly added to your site. The correct location will vary depending on your site’s setup, so you may have to double check where you are able to paste custom Javascript into your site. Since this isn’t a standard feature of Klaviyo, if you need more in-depth help with development, you can always reach out to one of wonderful Klaviyo Agency Partners.


I did also find this external article on how to install custom JavaScript on a WordPress site:


I hope this helps to clarify, and thanks for using the Community!

- Brian

Badge +3

Hey Brian,


Thanks for the response.

I tested with a email address that has been cookied and already tracking API calls through the website.

I can see the entire website activity “viewed product” & “add to cart” the nothing when the user visits the page with the code.
The script is implemented and located next to another similar script which is active and firing correctly.



Badge +3

So I was able to get it to work with the help of support by adding a bit of script to the same page.

<script type="text/javascript" async="" src=""></script>

With my company ID where those Xs are.

Userlevel 7
Badge +36

Hi @RedPhive!


Glad you were able to get in touch with Support and get it working! This will be a valuable reference for other Community members.


Thanks for using the Community!

- Brian