Przejdź do głównej treści
Polski— Wybierz język
Menu

Analiza sentymentu na platformie X

Lekcja 9 z 12 Zaktualizowano 30 lipca 2026 Średnio zaawansowani
Na tej stronie
  1. Zrozum, co naprawdę myśli Twoja publiczność
  2. Wymiary sentymentu w marketingu
  3. Analiza sentymentu za pomocą X Search i Grok
  4. Uzyskaj ustrukturyzowane wyniki w formacie JSON
  5. Śledź ewolucję sentymentu w czasie
  6. Wykrywaj kryzysy wizerunkowe
  7. Kluczowe wnioski

Zrozum, co naprawdę myśli Twoja publiczność

Analiza sentymentu przekształca tysiące postów w klarowny obraz tego, jak postrzegana jest Twoja marka, konkurencja lub cała branża. Dzięki funkcji wyszukiwania w X oraz możliwościom rozumowania modelu Grok możesz wyjść poza prostą klasyfikację pozytywny/negatywny i zrozumieć emocjonalne niuanse, ukryte frustracje oraz sygnały ostrzegawcze.

5
poziomów sentymentu
API
czas rzeczywisty
JSON
ustrukturyzowane wyjście
Wielo
wymiarowa analiza

Wymiary sentymentu w marketingu

Analiza sentymentu w marketingu wykracza poza binarny podział na pozytywny i negatywny. Oto kluczowe wymiary, które powinieneś brać pod uwagę:

5-stopniowa skala sentymentu

  1. Bardzo pozytywny: entuzjazm, aktywna rekomendacja, miłość do marki
  2. Pozytywny: zadowolenie, aprobata, zainteresowanie
  3. Neutralny: faktyczna wzmianka, udostępnianie informacji
  4. Negatywny: rozczarowanie, krytyka, frustracja
  5. Bardzo negatywny: gniew, wezwanie do bojkotu, kryzys

Dodatkowe wymiary

  • Intencja zakupowa: Czy post wskazuje na zamiar zakupu lub rezygnacji z usługi?
  • Wpływ: Czy post pochodzi od konta wpływowego, czy od przeciętnego konsumenta?
  • Wiralowość: Czy post ma potencjał szerokiego rozpowszechnienia?
  • Pilność: Czy sygnał wymaga szybkiej reakcji?

Analiza sentymentu za pomocą X Search i Grok

Analiza sentymentu dla Twojej marki

def analyser_sentiment_marque(marque, periode_jours=7):
    from datetime import datetime, timedelta

    today = datetime.now().strftime("%Y-%m-%d")
    start = (datetime.now() - timedelta(days=periode_jours)).strftime("%Y-%m-%d")

    response = client.responses.create(
        model="grok-4.20-0309-reasoning",
        input=f"""Analyze the sentiment of conversations on X
        about {marque} between {start} and {today}.

        For each conversation theme identified, provide:
        1. The theme (e.g., "customer service", "product quality")
        2. The dominant sentiment (1-5 scale)
        3. The estimated conversation volume
        4. The most representative verbatims
        5. The most influential accounts in the discussion
        6. Sentiment evolution over the period

        Final summary:
        - Global sentiment score (1-5)
        - Top 3 positive points
        - Top 3 negative points
        - Any alerts""",
        tools=[{
            "type": "x_search",
            "from_date": start,
            "to_date": today
        }]
    )
    return response.output_text

Porównawcza analiza sentymentu

Porównaj percepcję swojej marki z percepcją konkurencji:

def sentiment_comparatif(marques, periode_jours=30):
    from datetime import datetime, timedelta

    today = datetime.now().strftime("%Y-%m-%d")
    start = (datetime.now() - timedelta(days=periode_jours)).strftime("%Y-%m-%d")

    response = client.responses.create(
        model="grok-4.20-0309-reasoning",
        input=f"""Compare sentiment on X for these brands:
        {', '.join(marques)}

        Period: {start} to {today}

        For each brand, evaluate:
        - Global sentiment score (1-5, with decimal)
        - Dominant positive themes
        - Dominant negative themes
        - Strengths perceived by the public
        - Weaknesses perceived by the public

        Final comparison table ranked by sentiment.
        Identify positioning opportunities for the
        first brand in the list.""",
        tools=[{"type": "x_search", "from_date": start, "to_date": today}]
    )
    return response.output_text

Uzyskaj ustrukturyzowane wyniki w formacie JSON

Aby zintegrować analizę sentymentu z potokiem danych, zażądaj wyjścia w formacie JSON:

def sentiment_structure(marque, periode_jours=7):
    from datetime import datetime, timedelta

    today = datetime.now().strftime("%Y-%m-%d")
    start = (datetime.now() - timedelta(days=periode_jours)).strftime("%Y-%m-%d")

    response = client.responses.create(
        model="grok-4.20-0309-reasoning",
        input=f"""Analyze sentiment on X about {marque}.
        Period: {start} to {today}.

        Respond ONLY in valid JSON with this structure:
        {{
          "brand": "{marque}",
          "period": "{start} - {today}",
          "global_score": 3.7,
          "distribution": {{
            "very_positive": 15,
            "positive": 35,
            "neutral": 30,
            "negative": 15,
            "very_negative": 5
          }},
          "themes": [
            {{
              "name": "customer service",
              "score": 2.1,
              "volume": "high",
              "trend": "stable"
            }}
          ],
          "alerts": ["alert description if applicable"],
          "recommendations": ["recommended action"]
        }}""",
        tools=[{"type": "x_search", "from_date": start, "to_date": today}]
    )
    return response.output_text

Śledź ewolucję sentymentu w czasie

Jednorazowa analiza jest przydatna, ale śledzenie zmian w czasie ujawnia trendy. Porównuj wyniki tydzień po tygodniu:

def evolution_sentiment(marque, nb_semaines=4):
    from datetime import datetime, timedelta
    import json

    historique = []
    for i in range(nb_semaines, 0, -1):
        end = (datetime.now() - timedelta(weeks=i-1)).strftime("%Y-%m-%d")
        start = (datetime.now() - timedelta(weeks=i)).strftime("%Y-%m-%d")

        response = client.responses.create(
            model="grok-4.20-0309-reasoning",
            input=f"""Sentiment score on X for {marque}
            from {start} to {end}.
            Respond with a JSON: {{"week": "{start}",
            "score": X.X, "volume": N, "dominant_theme": "..."}}""",
            tools=[{
                "type": "x_search",
                "from_date": start,
                "to_date": end
            }]
        )
        historique.append(response.output_text)

    return historique

Wykrywaj kryzysy wizerunkowe

Analiza sentymentu to Twój pierwszy system alarmowy w przypadku kryzysu:

def detecter_crise(marque, seuil_negatif=40):
    resultat = sentiment_structure(marque, periode_jours=1)

    # Parse the JSON
    import json
    data = json.loads(resultat)

    pct_negatif = (data["distribution"]["negative"] +
                   data["distribution"]["very_negative"])

    if pct_negatif > seuil_negatif:
        return {
            "alert": True,
            "level": "CRITICAL" if pct_negatif > 60 else "IMPORTANT",
            "score": data["global_score"],
            "negative_themes": [t for t in data["themes"] if t["score"] < 2.5],
            "recommendation": "Crisis meeting recommended"
        }
    return {"alert": False, "score": data["global_score"]}

Kluczowe wnioski

  • Analiza sentymentu wykracza poza podział pozytywny/negatywny: oceniaj intencje, wpływ i pilność
  • Używaj 5-stopniowej skali, aby uchwycić niuanse
  • Żądaj ustrukturyzowanych wyników w formacie JSON, aby zasilać swoje dashboardy
  • Śledź ewolucję sentymentu w czasie, a nie tylko jednorazowe migawki
  • Systematycznie porównuj swój sentyment z sentymentem konkurencji
  • Skonfiguruj progi alertów, aby wykrywać kryzysy wizerunkowe w momencie ich pojawiania się