Skip to main content
Solved

Custom integration not showing any tracking events.


Forum|alt.badge.img+2
  • Contributor I
  • 1 reply

Hi,

 

I have integrated client/server side tracking in website (custom integration I have written), but doesn’t show any tracking events data on Klaviyo Dashboard, Analytics, or Active on Site. Created a campaign, sent out an email, clicked a link from the email to the website and then logged into the website, added an item to cart and placed an order. Even the simple Identity event does not show. Could anyone advise me what I have missed?

<head>

<script async src="https://static.klaviyo.com/onsite/js/klaviyo.js?company_id=MY_PUBLIC_API_KEY"></script>
<script>var _learnq = _learnq || [];</script>

</head>

<body>

<script>
_learnq.push(["Identity", {
    "$email": "email@email.com",
    "$first_name": "First",
    "$last_name": "Last",
    "$phone_number": "00000000"
}]);
</script>

</body>

Thanks

Ray

Best answer by David To

Hello@Ray,

Welcome to the Klaviyo Community!

If you haven’t already, I think it would be helpful to take a look at our Integrate a platform without a pre-built Klaviyo integration Developer guide.

Since you’re using a custom integration with Klaviyo, in order to record those various events such as add to cart, placed order, etc, you’ll need to set up a series of JavaScript Track API calls and server-side Track API depending on the event you’re trying to record. One thing I also noticed was that it doesn’t seem like your onsite/identify call is actually being setup correctly. For example, we suggest using the following JavaScript API to track people on your website:

// Replace "PUBLIC_API_KEY" with your real API key.
<script
  async type="text/javascript"
  src="//static.klaviyo.com/onsite/js/klaviyo.js?company_id=PUBLIC_API_KEY"
></script>

<script>
  var _learnq = _learnq || [];
  _learnq.push(['identify', {
    // Change the line below to dynamically print the user's email.
    '$email' : '{{ email }}'
  }]);
</script>

Compared to the existing code you’re using, there seems to be some discrepancy - example being the missing type="text/javascript" portion - which you may want to review further and adjust. I would also suggest taking a look at some further resources we offer in our Developer Portal which includes our helpful guides and a list of our API endpoints. In the event you’re really stuck and need some hands on assistance, you can also always reach out to our expansive network of Klaviyo Partners which offer development assistance. 

I hope this helps!

David

View original
Did this topic or the replies in the thread help you find an answer to your question?

2 replies

David To
Klaviyo Employee
Forum|alt.badge.img+60
  • Klaviyo Employee
  • 2456 replies
  • Answer
  • August 30, 2022

Hello@Ray,

Welcome to the Klaviyo Community!

If you haven’t already, I think it would be helpful to take a look at our Integrate a platform without a pre-built Klaviyo integration Developer guide.

Since you’re using a custom integration with Klaviyo, in order to record those various events such as add to cart, placed order, etc, you’ll need to set up a series of JavaScript Track API calls and server-side Track API depending on the event you’re trying to record. One thing I also noticed was that it doesn’t seem like your onsite/identify call is actually being setup correctly. For example, we suggest using the following JavaScript API to track people on your website:

// Replace "PUBLIC_API_KEY" with your real API key.
<script
  async type="text/javascript"
  src="//static.klaviyo.com/onsite/js/klaviyo.js?company_id=PUBLIC_API_KEY"
></script>

<script>
  var _learnq = _learnq || [];
  _learnq.push(['identify', {
    // Change the line below to dynamically print the user's email.
    '$email' : '{{ email }}'
  }]);
</script>

Compared to the existing code you’re using, there seems to be some discrepancy - example being the missing type="text/javascript" portion - which you may want to review further and adjust. I would also suggest taking a look at some further resources we offer in our Developer Portal which includes our helpful guides and a list of our API endpoints. In the event you’re really stuck and need some hands on assistance, you can also always reach out to our expansive network of Klaviyo Partners which offer development assistance. 

I hope this helps!

David


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 1 reply
  • August 30, 2022

Hi David,

Updated as you advised, but still no luck. Any suggestions?

Should scripts be placed into head tag?