Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Youtube APi Fetching Gender Percentage of my channel

$
0
0

I am trying to fetch percentage of gender in my channel but it's showing me 92% male and 8% female but when i check it through the youtube studio it's show me 85% male and 15% female why this code is giving me wrong data or am I doing it wrong?:

here is the code

try {     const startDate = "2005-02-14"; // Fallback to YouTube's start date     const endDate = new Date().toISOString().split("T")[0]; // Current date in YYYY-MM-DD format     const analytics = google.youtubeAnalytics({      version: "v2",      auth: oauth2Client,    });      const analyticsResponse = await analytics.reports.query({        ids: `channel==${channelId}`,        startDate,        endDate,        dimensions: "gender,subscribedStatus",        metrics: "viewerPercentage",        // filters: "audienceType==ORGANIC",      });      demographicData.gender = analyticsResponse.data.rows.map((row) => ({        gender: row[0],        viewerPercentage: row[1],      }));      console.log("analyticsResponse: ", analyticsResponse.data);      console.log("demographicData: ", demographicData.gender);} catch (error) {      console.error("Error fetching gender data:", error);}

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>