Automating CTAs on blogposts (COS)

SOLVE
Patryk
Member

Hello,

 

As of today, we have a simple hack to change CTAs on multple blogposts at once:

{% if 'iOS' in content.topic_list %}
    {% cta 'new_cta' label='Select iOS CTA', guid='a568423d-d082-4f89-a03e-e35a3baaa4ee' %}
  {% elif 'Android' in content.topic_list|map('name') %}
    {% cta 'new_cta' label='Select Android CTA', guid='a568423d-d082-4f89-a03e-e35a3baaa4ee' %}

Inside Hubspot, we have ex. "Topic CTA: iOS" which we can change and it should update on every blogpost with given topic.

 

We have three problems, though:

1. If CTA is being manually changed inside blogpost, it won't update

2. CTA is chosen based on "first" topic, which is pretty random and if we have multiple topics set up in the example of code above, it's getting hard to keep up

3. This is a highly technical solution and difficult to manage

 

I was wondering if any of you did similar things and share your solution or some tips?

1 Accepted solution

Accepted Solutions
Patryk
Solution
Member

Thanks @stefen.

Actually, when thinking about the solution I came up with something better using HubDB:

{% if content.campaign_name %}
  {% for row in hubdb_table_rows(669337) %}
    {% if row.campaign_name == content.campaign_name %}
      {{ cta(row.cta_id) }}
    {% endif %}
  {% endfor %}
{% else %}
  {% set row = hubdb_table_row(669337, 5168641782) %}
  {{ cta(row.cta_id) }}
{% endif %}

Now our content team has a nice table where they can assign CTA ids to campaign names.

It's not perfect as I can't set "placeholder" CTA when campaign has no CTA assigned, but overall I'm happy with it.

Hope it helps somebody!

View solution in original post

3 Replies 3
nicolebrenner
HubSpot Employee

Thanks for sharing! @stefen do you have any feedback to share regarding @Patryk 's issues here?

0 Upvotes
stefen
Key Advisor | Partner

@Patryk neat trick!

 

I think if you moved the if statement inside the topic loop you could solve problem 2. For example:

{% for topic in content.topic_list %}
  {% if 'iOS' in topic.name %}
    ... CTA ...
  {% endif %}
{% endfor %}
Stefen Phelps, Community Champion, Kelp Web Developer
Patryk
Solution
Member

Thanks @stefen.

Actually, when thinking about the solution I came up with something better using HubDB:

{% if content.campaign_name %}
  {% for row in hubdb_table_rows(669337) %}
    {% if row.campaign_name == content.campaign_name %}
      {{ cta(row.cta_id) }}
    {% endif %}
  {% endfor %}
{% else %}
  {% set row = hubdb_table_row(669337, 5168641782) %}
  {{ cta(row.cta_id) }}
{% endif %}

Now our content team has a nice table where they can assign CTA ids to campaign names.

It's not perfect as I can't set "placeholder" CTA when campaign has no CTA assigned, but overall I'm happy with it.

Hope it helps somebody!

View solution in original post