This article will show you how to install Klaviyo.js into your project.
Install Klaviyo.js into your project by copying the code snippet below and pasting it into the project code before the closing body tag.
Be sure to replace "PUBLIC_API_KEY" with your Public API Key from Klaviyo.
<script type="application/javascript" async
src="https://static.klaviyo.com/onsite/js/klaviyo.js?company_id=PUBLIC_API_KEY"></script>
You can add extra snippets of code to identify your customers with any information they have submitted.
<script>
var _learnq = _learnq || [];
_learnq.push(['identify', {
'$email': '{{emailAddress }}',
'$first_name': '{{ firstName }}',
'$last_name': '{{ lastName }}'
}]);
</script>Additional tokens you can pass into Klaviyo:
{{emailAddress}}
{{firstName}}
{{lastName}}
{{this.phoneNumber}}
{{city}}
{{postalCode}}
{{state}}
{{country}}
{{sf-session-id}}Please visit Klaviyo developer documents for additional information.
Select the code editor in Subscribe Funnels
Paste the Klaviyo code into Subscribe Funnels
Place the scripts at the end of your code.