Solved

Data is not sent to Klaviyo.

  • 22 December 2021
  • 3 replies
  • 147 views

Badge

Hi all,
I've used Klaviyo to send Email for a service in my WordPress website. I can’t find the problem since I receive no errors in response from Klaviyo. I found that if the user is registered in Klaviyo then the email will be sent, if not, no email will be sent.

You can find the complete source code Coo Coo! (pigeonsdontcry.com).

<script type="text/javascript">
            var _learnq = _learnq || [];

            jQuery.post('https://a.klaviyo.com/api/identify', {data: '{"token": "XXXXXX","properties": {"$email":"teset1@gmail.com"}}'}, function(result){
                console.log('Result', result);
            });
            var item = {
                'ap_poster_number':'1234456',
                'poster_url':'https://pigeonsdontcry.com/posters/' + 'Antwerp ',
                'ap_poster_auth':'1837987',
                'poster_name':'Antwerp ',
                'poster_image':'https://pigeonsdontcry.com/wp-content/uploads/2016/04/posterantwerp.jpg',
                'ap_name':'Soha A.',
                'ap_street_and_number':'Address Line 1',
                'ap_apartment':'',
                'ap_postal_code':'32165',
                'ap_city':'London',
                'ap_country':'United Kingdom',
                'ap_map':'0',
                'ap_room':'Living Room',
                'ap_next_poster':'Oslo',
                'ap_poster_hero_image':'https://pigeonsdontcry.com/wp-content/plugins/ownership/assets/images/cabinet-antwerp-front-mail-hero.jpg',
                'email':'teset1@gmail.com'
            };
            _learnq.push(['track', 'PosterAuthentication', item])
        </script>

icon

Best answer by David To 23 December 2021, 20:14

View original

3 replies

Userlevel 7
Badge +48

Hello @soha.a,

Welcome to the Klaviyo Community! 

From the code you provided, it looks like you are making a POST request to record a custom event to Klaviyo. I think it would be really helpful if you provided more information and details pertaining to what it is you were trying to accomplish.

Troubleshooting custom codes can be hard as it pertains to a number of variables that can potentially be the cause of an issue. For this reason I would suggest reaching out to a developer you are familiar with who is knowledgable about Klaviyo’s API or to an accredited Klaviyo Partner who can further review your code and how things are set up. 

From my experience, a common reason why a custom event may not be triggered or registering within an account is that it is being rate limited. There’s been several posts pertaining to this topic which I’ve included below that may be of use:

I hope this helps!

David

Badge

Thanks David for your attention, I have a custom flow that when a user submit his/her information for the product they bought, I send an email to greeting the user with that data. I asked another developer, he told me that I have to register the user email in Klaviyo first and then send the second POST request. Since I didn’t find any documentation about how to register an email to Klaviyo with API I added identify POST request to my script with user entered email which is as example

jQuery.post('https://a.klaviyo.com/api/identify', {data: '{"token": "XXXXXX","properties": {"$email":"teset1@gmail.com"}}'}, function(result){
                console.log('Result', result);
            });

but nothing is received to Klaviyo or I can’t find it in Activity Feed.

I hope I could explain what was the problem.
Reagrds,
Soha A.
 

Userlevel 7
Badge +48

Hey @soha.a,

Thanks for those additional details. Although it is possible to include an Identify call as part of your overall payload, its typically best practice to separate operations so to have different functions/scripts specific to each call. Your developer’s suggestions would be correct where two steps would be following best practices; one to register and identify the user and the second to POST the request for the identified user. 

If you haven’t already, I would suggest taking a look at some resources found within our API Documentation that discusses more on the matter of identifying users via API:

David


 

Reply