Hi everyone,
I am trying to create a custom restocking form for all the product pages of our Shopify store with the idea that whoever signs up, their email address gets added to a list on Klaviyo and a property on their profiles gets updated with the product title.
I referred to some useful articles like this one (https://elghorfimed.medium.com/easy-steps-to-add-a-custom-legacy-embedded-email-signup-form-in-shopify-3d999390c4c5) and created the following code (omitting the styles):
-------------------------------------------------------------------------------------------
<form novalidate="novalidate" method="GET" data-ajax-submit="//manage.kmail-lists.com/ajax/subscriptions/subscribe" action="//manage.kmail-lists.com/subscriptions/subscribe" class="klaviyo_styling klaviyo_gdpr_embed_VOBQyb" id="email_signup" target="_blank"><input value="VOBQyb" name="g" type="hidden">
<div class="klaviyo_field_group"><label for="k_id_email">Restock Sign Up</label> <input placeholder="Your email" id="k_id_email" name="email" value="" type="email" class=""></div>
<div class="klaviyo_messages">
<div style="display: none;" class="success_message"></div>
<div style="display: none;" class="error_message"></div>
</div>
<div class="klaviyo_form_actions"><button class="klaviyo_submit_button" type="submit">Subscribe</button></div>
</form>
<script type="text/javascript" src="//www.klaviyo.com/media/js/public/klaviyo_subscribe.js"></script> <script type="text/javascript">
var productName = '{{product.title}}';
KlaviyoSubscribe.attachToForms('#email_signup', {
hide_form_on_success: true,
success_message: "Thank you for your interest in this product! We will surely keep you informed if and when it is restocked.",
extra_properties: {
$test_property: productName,
$source: '$embed',
$method_type: "Klaviyo Form",
$method_id: 'embed',
$consent_version: 'Embed default text'
}
});
</script>
-------------------------------------------------------------------------------------------
The form works to the extent that it adds the email to this particular list id on our Klaviyo and also creates and adds the product title to the property $test_property. However, the issue is that if I fill up the form with the same email address on a different product page, the property $test_property gets overwritten.
How can I change this form so that the property $test_property gets created if it doesn’t exist but gets appended if it exists already so that we can track all the restocking requests from a particular customer?
Any help will be greatly appreciated.
Thank you.