Solved

How to add marketing code to sign up form

  • 26 January 2022
  • 2 replies
  • 29 views

Badge

Hi there,

I’m trying to create a pop-up sign up form where I’m asking for customers name, email and phone number. Straight forward enough.

But I also want to record the customers marketing channel against their record if they sign up.

What is the best way to do this? 

I tried adding some custom jquery that added it to an additional form field but the inputted value kept getting overwritten when I clicked on another field.

Is there a proper way to do this with Klaviyo?

My marketing channel/code will be held in local storage.

Thanks!

icon

Best answer by MattS 27 January 2022, 14:47

View original

2 replies

Badge

UPDATE:

Just read the documentation on Klaviyo and have achieved this by using the addEventListener custom code :)

  var _learnq = window._learnq || [];
  window.addEventListener("klaviyoForms", function(e) { 
    if (e.detail.type == 'open') {
      _learnq.push(['identify', {
      'marketing-channel' : 'test',
    }]);
 }});

I did notice that the official documentation is missing a closing curly bracket, I’ve highlighted it in yellow.

https://help.klaviyo.com/hc/en-us/articles/360003953111-How-to-Add-Custom-JavaScript-Events-to-Forms

Userlevel 7
Badge +49

Hey @MattS,

Thanks for bringing this to our attention! I’ve surfaced this with our documentation team to get it corrected!

Glad you were able to share your findings with the rest of the Community as well!

Thanks for being a part of the Klaviyo Community!

David

Reply