Zum Inhalt

Tags

Mit Tags segmentieren Sie Ihre Subscriber-Basis nach Interessen, Themen oder beliebigen Kategorien. Subscriber können mehrere Tags haben, und Tags können öffentlich (im Preference Center sichtbar) oder privat (nur intern) sein.

Tag erstellen

tag = await client.tags.create(
    name="Product Updates",
    description="Neue Features und Verbesserungen",
    category="product",
    is_public=True,
)
print(f"Erstellt: {tag.name} ({tag.slug})")
const tag = await client.tags.create({
  name: 'Product Updates',
  description: 'Neue Features und Verbesserungen',
  category: 'product',
  is_public: true,
});

console.log('Erstellt:', tag.name, `(${tag.slug})`);
curl -X POST https://api.subscribeflow.net/api/v1/tags \
  -H "X-API-Key: sf_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Product Updates",
    "description": "Neue Features und Verbesserungen",
    "category": "product",
    "is_public": true
  }'

Info

Ein URL-sicherer slug wird automatisch aus dem Tag-Namen generiert. Sie können auch einen eigenen Slug angeben.

Tags auflisten und filtern

Rufen Sie alle Tags ab oder filtern Sie nach Kategorie.

# Alle Tags
tags = await client.tags.list()
for tag in tags:
    print(f"{tag.name}: {tag.subscriber_count} Subscriber")

# Nach Kategorie filtern
product_tags = await client.tags.list(category="product")
// Alle Tags
const { items } = await client.tags.list();
for (const tag of items) {
  console.log(`${tag.name}: ${tag.subscriber_count} Subscriber`);
}

// Nach Kategorie filtern
const productTags = await client.tags.list({ category: 'product' });
# Alle Tags
curl https://api.subscribeflow.net/api/v1/tags \
  -H "X-API-Key: sf_live_..."

# Nach Kategorie filtern
curl "https://api.subscribeflow.net/api/v1/tags?category=product" \
  -H "X-API-Key: sf_live_..."

Subscriber-Anzahl abrufen

Jede Tag-Antwort enthält ein Feld subscriber_count. Sie können auch einen einzelnen Tag abrufen, um die aktuelle Anzahl zu prüfen.

tag = await client.tags.get("tag-id")
print(f"{tag.name} hat {tag.subscriber_count} Subscriber")
const tag = await client.tags.get('tag-id');
console.log(`${tag.name} hat ${tag.subscriber_count} Subscriber`);
curl https://api.subscribeflow.net/api/v1/tags/TAG_ID \
  -H "X-API-Key: sf_live_..."

Tag aktualisieren

await client.tags.update(
    "tag-id",
    description="Woechentliche Produkt-Updates und Release Notes",
    is_public=True,
)
await client.tags.update('tag-id', {
  description: 'Woechentliche Produkt-Updates und Release Notes',
  is_public: true,
});
curl -X PATCH https://api.subscribeflow.net/api/v1/tags/TAG_ID \
  -H "X-API-Key: sf_live_..." \
  -H "Content-Type: application/json" \
  -d '{"description": "Woechentliche Produkt-Updates und Release Notes", "is_public": true}'

Tag archivieren (Soft Delete)

Das Löschen eines Tags entfernt ihn aus dem System. Bestehende Subscriber-Zuordnungen werden entfernt, die Subscriber selbst bleiben erhalten.

await client.tags.delete("tag-id")
await client.tags.delete('tag-id');
curl -X DELETE https://api.subscribeflow.net/api/v1/tags/TAG_ID \
  -H "X-API-Key: sf_live_..."

Warning

Das Löschen eines Tags meldet alle zugeordneten Subscriber von diesem Tag ab. Dies kann nicht rückgängig gemacht werden.

Hands-On: Ihre Zielgruppe mit Tags segmentieren

Erstellen Sie thematische Tags und weisen Sie sie Subscribern zu. Dieses Beispiel richtet eine grundlegende interessenbasierte Segmentierung ein.

import asyncio
from subscribeflow import SubscribeFlowClient

async def main():
    async with SubscribeFlowClient(api_key="sf_live_...") as client:
        # Themen-Tags erstellen
        for tag_name in ["Engineering Blog", "Product Updates", "Events"]:
            await client.tags.create(
                name=tag_name,
                category="content",
                is_public=True,
            )

        # Bestehende Subscriber taggen
        await client.subscribers.add_tags(
            "subscriber-id",
            tags=["engineering-blog", "events"],
        )
        print("Subscriber erfolgreich getaggt")

asyncio.run(main())
import { SubscribeFlowClient } from '@subscribeflow/sdk';

const client = new SubscribeFlowClient({
  apiKey: 'sf_live_...',
});

// Themen-Tags erstellen
for (const name of ['Engineering Blog', 'Product Updates', 'Events']) {
  await client.tags.create({
    name,
    category: 'content',
    is_public: true,
  });
}

// Bestehende Subscriber taggen
await client.subscribers.addTags('subscriber-id', {
  tags: ['engineering-blog', 'events'],
});

console.log('Subscriber erfolgreich getaggt');
# Tags erstellen
for TAG in "Engineering Blog" "Product Updates" "Events"; do
  curl -X POST https://api.subscribeflow.net/api/v1/tags \
    -H "X-API-Key: sf_live_..." \
    -H "Content-Type: application/json" \
    -d "{\"name\": \"$TAG\", \"category\": \"content\", \"is_public\": true}"
  echo
done

# Subscriber taggen
curl -X POST https://api.subscribeflow.net/api/v1/subscribers/SUBSCRIBER_ID/tags \
  -H "X-API-Key: sf_live_..." \
  -H "Content-Type: application/json" \
  -d '{"tags": ["engineering-blog", "events"]}'