Changing button color dynamically | Community
Skip to main content
New Participant
February 24, 2022
Solved

Changing button color dynamically

  • February 24, 2022
  • 1 reply
  • 4336 views

Hey all, is there any way to change color of the CTA button dynamically in landing pages.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Darshil_Shah1

If it's Marketo LP - and you wanna leverage cookied record's data/Marketo's inferred data e.g., location for customizing the button color you can define various possible buttons styles within the dynamic snippet for each segment, which will help you get away from the custom JS. 🙂 

Just as an FYI: Dynamic snippets are tied to a database segmentation and will show different content to visitors based on which segment they belong to.

1 reply

SanfordWhiteman
New Participant
February 24, 2022

Of course! A Marketo LP is just an HTML + CSS + JS page.

 

If you structure your HTML so that a CSS class determines the button color, you can switch the CSS class using JS, or output it using a {{my.token}} or ${variable}, or... so many things.

 

But your description is pretty vague. “Dynamically” according to what factors?

Sreeja06Author
New Participant
February 24, 2022

I want color of this button to change dynamically according to the segmentations defined.

SanfordWhiteman
New Participant
February 24, 2022

Put different variations of a <style> tag in a segmented Rich Text area.