Skip to main content

On Shopify, I have two different embed codes, one for desktop only and one for mobile only.  When I put the different codes in to Shopify using the Klaviyo embed app, only one will show.

On the shopify preview they work but on the live site only one works. How can I get each to show depending on whether it is for desktop or mobile? At the moment only the mobile form is showing and not the desktop form on the live website…...

Hey @jossd 

I think you will have to add or edit the css file to add queries to control the visibility of the forms based on the device screen size.

For the desktop form, wrap the embed code in a <div> with a class

For the Mobile form, wrap the embed code in a <div> with a different class

something like below

<!-- Desktop Form Embed Code -->
<div class="klaviyo-form klaviyo-form-desktop">
<!-- Your desktop Klaviyo embed code goes here -->
</div>

<!-- Mobile Form Embed Code -->
<div class="klaviyo-form klaviyo-form-mobile">
<!-- Your mobile Klaviyo embed code goes here -->
</div>

In your theme's CSS file (e.g., theme.css or styles.css), add the following CSS:

/* Hide mobile form by default */
.klaviyo-form-mobile {
display: none;
}

/* Show desktop form by default */
.klaviyo-form-desktop {
display: block;
}

/* Media query for mobile devices */
@media (max-width: 767px) {
/* Show mobile form on mobile devices */
.klaviyo-form-mobile {
display: block;
}
/* Hide desktop form on mobile devices */
.klaviyo-form-desktop {
display: none;
}
}

Now test this on different devices. let me know if it works

Cheers and thank you for being part of this community

Arpit


Reply