if (!empty($adminPanelSettings['facebook_pixel_id'])) { echo "\n"; echo "\n"; } else { echo getFacebookPixelCode(); } // Custom head code from admin panel if (!empty($adminPanelSettings['custom_head_code'])) { echo $adminPanelSettings['custom_head_code']; } ?>

Free Tag Frequency Counter

Count and analyze HTML tag frequency in web pages. Identify tag distribution, optimize HTML structure, and improve website performance and SEO.

Tag Analysis
Distribution Charts
HTML Optimization

Tag Frequency Counter

Analyze HTML tag usage and optimize your website structure

0 tags detected
Analysis Options
SEO Optimization

Analyze heading tag distribution and structure for better search engine optimization.

Performance

Identify excessive tag usage that might impact page loading speed and performance.

Code Quality

Ensure proper HTML structure and semantic markup for better accessibility.

`; } function extractTagsFromHtml(html) { if (!html.trim()) return []; const caseSensitive = document.getElementById('caseSensitive').checked; const includeAttributes = document.getElementById('includeAttributes').checked; // Extract all HTML tags const tagRegex = /<\/?([a-zA-Z][a-zA-Z0-9]*)[^>]*>/g; const tags = []; let match; while ((match = tagRegex.exec(html)) !== null) { let tagName = match[1]; if (!caseSensitive) { tagName = tagName.toLowerCase(); } // Skip closing tags for counting if (!match[0].startsWith('') }); } } return tags; } function displayResults() { updateSummaryStats(); displayFrequencyDistribution(); displayTagCategories(); generateOptimizationTips(); resultsSection.style.display = 'block'; resultsSection.scrollIntoView({ behavior: 'smooth' }); } function updateSummaryStats() { const totalTags = analysisResults.length; const uniqueTags = new Set(analysisResults.map(tag => tag.name)).size; // Count frequency const frequency = {}; analysisResults.forEach(tag => { frequency[tag.name] = (frequency[tag.name] || 0) + 1; }); // Find most used tag const sortedTags = Object.entries(frequency).sort(([,a], [,b]) => b - a); const mostUsedTag = sortedTags.length > 0 ? sortedTags[0][0] : '-'; const topTagCount = sortedTags.length > 0 ? sortedTags[0][1] : 0; const topTagPercentage = totalTags > 0 ? ((topTagCount / totalTags) * 100).toFixed(1) : 0; document.getElementById('totalTags').textContent = totalTags; document.getElementById('uniqueTags').textContent = uniqueTags; document.getElementById('mostUsedTag').textContent = mostUsedTag; document.getElementById('topTagPercentage').textContent = topTagPercentage + '%'; } function displayFrequencyDistribution() { const showPercentages = document.getElementById('showPercentages').checked; // Count frequency const frequency = {}; analysisResults.forEach(tag => { frequency[tag.name] = (frequency[tag.name] || 0) + 1; }); // Sort by frequency const sortedTags = Object.entries(frequency).sort(([,a], [,b]) => b - a); const totalTags = analysisResults.length; const maxCount = sortedTags.length > 0 ? sortedTags[0][1] : 1; const container = document.getElementById('frequencyResults'); if (sortedTags.length === 0) { container.innerHTML = '
No tags found
'; return; } const resultsHtml = sortedTags.map(([tagName, count]) => { const percentage = ((count / totalTags) * 100).toFixed(1); const barWidth = (count / maxCount) * 100; return `
<${tagName}>
${count} ${showPercentages ? `${percentage}%` : ''}
`; }).join(''); container.innerHTML = resultsHtml; } function displayTagCategories() { const categories = { 'Structure': ['html', 'head', 'body', 'header', 'main', 'footer', 'section', 'article', 'aside', 'nav'], 'Content': ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'div', 'span', 'blockquote', 'pre'], 'Lists': ['ul', 'ol', 'li', 'dl', 'dt', 'dd'], 'Media': ['img', 'video', 'audio', 'source', 'track', 'canvas', 'svg'], 'Forms': ['form', 'input', 'textarea', 'select', 'option', 'button', 'label', 'fieldset', 'legend'], 'Links': ['a', 'link'], 'Tables': ['table', 'thead', 'tbody', 'tfoot', 'tr', 'th', 'td', 'caption', 'colgroup', 'col'], 'Meta': ['meta', 'title', 'base', 'style', 'script', 'noscript'], 'Formatting': ['strong', 'em', 'b', 'i', 'u', 'small', 'mark', 'del', 'ins', 'sub', 'sup'] }; const tagCounts = {}; analysisResults.forEach(tag => { tagCounts[tag.name] = (tagCounts[tag.name] || 0) + 1; }); const categorizedTags = {}; Object.entries(categories).forEach(([category, tags]) => { categorizedTags[category] = tags.filter(tag => tagCounts[tag]); }); const container = document.getElementById('categoriesGrid'); const categoriesHtml = Object.entries(categorizedTags) .filter(([category, tags]) => tags.length > 0) .map(([category, tags]) => `
${category}
${tags.map(tag => `${tag}`).join('')}
`).join(''); container.innerHTML = categoriesHtml || '
No categorized tags found
'; } function generateOptimizationTips() { const tips = []; const tagCounts = {}; analysisResults.forEach(tag => { tagCounts[tag.name] = (tagCounts[tag.name] || 0) + 1; }); // Check for heading structure const headings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']; const headingCounts = headings.map(h => tagCounts[h] || 0); if (tagCounts['h1'] === 1) { tips.push({ type: 'good', title: '✅ Single H1 Tag', description: 'Perfect! You have exactly one H1 tag, which is ideal for SEO.' }); } else if (tagCounts['h1'] > 1) { tips.push({ type: 'warning', title: '⚠️ Multiple H1 Tags', description: `Found ${tagCounts['h1']} H1 tags. Consider using only one H1 per page for better SEO.` }); } else if (!tagCounts['h1']) { tips.push({ type: 'error', title: '❌ Missing H1 Tag', description: 'No H1 tag found. Add an H1 tag for better SEO and accessibility.' }); } // Check for excessive div usage const divCount = tagCounts['div'] || 0; const totalTags = analysisResults.length; const divPercentage = (divCount / totalTags) * 100; if (divPercentage > 30) { tips.push({ type: 'warning', title: '⚠️ Excessive DIV Usage', description: `DIVs make up ${divPercentage.toFixed(1)}% of your tags. Consider using semantic HTML elements.` }); } // Check for semantic elements const semanticTags = ['header', 'main', 'footer', 'section', 'article', 'aside', 'nav']; const semanticCount = semanticTags.reduce((sum, tag) => sum + (tagCounts[tag] || 0), 0); if (semanticCount > 0) { tips.push({ type: 'good', title: '✅ Semantic HTML', description: `Good use of semantic elements (${semanticCount} found). This improves accessibility and SEO.` }); } else { tips.push({ type: 'warning', title: '⚠️ No Semantic Elements', description: 'Consider using semantic HTML5 elements like header, main, section, and footer.' }); } // Check for images without alt text analysis const imgCount = tagCounts['img'] || 0; if (imgCount > 0) { tips.push({ type: 'good', title: '📷 Images Found', description: `${imgCount} image tags detected. Ensure all have descriptive alt attributes for accessibility.` }); } const tipsHtml = tips.map(tip => `
${tip.title}
${tip.description}
`).join(''); document.getElementById('optimizationTips').innerHTML = tipsHtml; } window.pasteUrl = async function() { try { const text = await navigator.clipboard.readText(); pageUrl.value = text; } catch (err) { alert('Unable to access clipboard. Please paste manually.'); } }; window.loadSampleHtml = function() { const sampleHtml = ` Sample Page for Tag Analysis

Welcome to Our Website

Our Services

We provide excellent services to our clients.

Features

Feature 1

Description of feature 1.

Feature 2

Description of feature 2.

Feature 3

Description of feature 3.

What Our Clients Say

"This is an amazing service!"

- Happy Customer
`; htmlInput.value = sampleHtml; updateTagCount(); }; window.exportResults = function() { if (analysisResults.length === 0) { alert('No results to export'); return; } const frequency = {}; analysisResults.forEach(tag => { frequency[tag.name] = (frequency[tag.name] || 0) + 1; }); const sortedTags = Object.entries(frequency).sort(([,a], [,b]) => b - a); const totalTags = analysisResults.length; const csvContent = 'Tag,Count,Percentage\n' + sortedTags.map(([tag, count]) => { const percentage = ((count / totalTags) * 100).toFixed(1); return `"${tag}",${count},${percentage}%`; }).join('\n'); const blob = new Blob([csvContent], { type: 'text/csv' }); const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `tag-frequency-analysis-${new Date().toISOString().split('T')[0]}.csv`; a.click(); window.URL.revokeObjectURL(url); }; window.copyResults = function() { if (analysisResults.length === 0) { alert('No results to copy'); return; } const frequency = {}; analysisResults.forEach(tag => { frequency[tag.name] = (frequency[tag.name] || 0) + 1; }); const sortedTags = Object.entries(frequency).sort(([,a], [,b]) => b - a); const results = sortedTags.map(([tag, count]) => `${tag}: ${count}`).join('\n'); navigator.clipboard.writeText(results).then(() => { alert('Results copied to clipboard!'); }); }; window.clearResults = function() { pageUrl.value = ''; htmlInput.value = ''; resultsSection.style.display = 'none'; analysisResults = []; updateTagCount(); }; // Initialize updateTagCount(); });