Adding tracking code to your website allows you to gather data on visitor behavior, such as page views, clicks, and conversions. The most common tracking tool is Google Analytics, but there are many other tools like Facebook Pixel, Hotjar, and others. Here’s a general guide on how to add tracking code to your website.
Steps to Add Tracking Code:
1. Choose a Tracking Tool
- Google Analytics: Best for comprehensive tracking of website traffic and user behavior.
- Facebook Pixel: Ideal for tracking conversions from Facebook ads.
- Hotjar: Great for heatmaps and user interaction recording.
2. Get the Tracking Code
Each tracking tool will provide a unique snippet of JavaScript code once you sign up and set up tracking for your site. Here’s how you can get the code for Google Analytics:
- Go to Google Analytics.
- Create or select an account.
- Go to Admin > Tracking Info > Tracking Code.
- Copy the code snippet.
3. Place the Tracking Code on Your Website
Typically, you will place the tracking code in the <head>
section of your website so it loads on every page.
For HTML Websites:
htmlCopy code<head>
<!-- Your existing head content -->
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'YOUR_TRACKING_ID');
</script>
</head>
Replace YOUR_TRACKING_ID
with your actual tracking ID provided by Google Analytics.
For WordPress Websites: You can either:
- Install a plugin like Google Site Kit or Insert Headers and Footers to easily add tracking code without editing the theme files.
- Manually add the code in your theme’s
header.php
file before the closing</head>
tag.
4. Verify the Tracking Code
After adding the code, you should verify that it is working:
- Use Google Tag Assistant (a Chrome extension) to check if the code is correctly installed.
- In Google Analytics, check Real-Time reports to see live data.
5. Test the Tracking
Make sure to visit your site from different devices and check if the visits are being logged in the tracking tool.
अपनी वेबसाइट में ट्रैकिंग कोड जोड़ना
अपनी वेबसाइट में ट्रैकिंग कोड जोड़ने से आप विज़िटर व्यवहार, जैसे पेज व्यू, क्लिक, और कंवर्ज़न के बारे में डेटा एकत्र कर सकते हैं। सबसे सामान्य ट्रैकिंग टूल Google Analytics है, लेकिन अन्य टूल भी हैं जैसे Facebook Pixel, Hotjar, आदि। यहां वेबसाइट में ट्रैकिंग कोड जोड़ने की सामान्य प्रक्रिया दी गई है।
ट्रैकिंग कोड जोड़ने के चरण:
1. ट्रैकिंग टूल चुनें
- Google Analytics: वेबसाइट ट्रैफिक और उपयोगकर्ता व्यवहार की व्यापक ट्रैकिंग के लिए सबसे अच्छा है।
- Facebook Pixel: Facebook विज्ञापनों से कंवर्ज़न ट्रैक करने के लिए।
- Hotjar: हीटमैप और उपयोगकर्ता इंटरैक्शन रिकॉर्डिंग के लिए आदर्श।
2. ट्रैकिंग कोड प्राप्त करें
प्रत्येक ट्रैकिंग टूल एक यूनिक जावास्क्रिप्ट कोड स्निपेट प्रदान करता है। उदाहरण के लिए, Google Analytics का कोड इस प्रकार प्राप्त कर सकते हैं:
- Google Analytics पर जाएं।
- एक खाता बनाएं या किसी मौजूदा खाते का चयन करें।
- Admin > Tracking Info > Tracking Code पर जाएं।
- कोड स्निपेट कॉपी करें।
3. ट्रैकिंग कोड वेबसाइट पर लगाएं
आमतौर पर, ट्रैकिंग कोड को वेबसाइट के <head>
सेक्शन में डाला जाता है ताकि यह हर पेज पर लोड हो सके।
HTML वेबसाइट्स के लिए:
htmlCopy code<head>
<!-- आपका मौजूदा हेड कंटेंट -->
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'YOUR_TRACKING_ID');
</script>
</head>
YOUR_TRACKING_ID
को अपने वास्तविक Google Analytics ट्रैकिंग आईडी से बदलें।
WordPress वेबसाइट्स के लिए: आप निम्नलिखित में से कोई एक तरीका अपना सकते हैं:
- Google Site Kit या Insert Headers and Footers जैसे प्लगइन का उपयोग कर सकते हैं, जिससे आपको थीम फाइल एडिट किए बिना ट्रैकिंग कोड जोड़ने में आसानी होगी।
- या आप थीम की
header.php
फ़ाइल में कोड को</head>
टैग से पहले मैन्युअली जोड़ सकते हैं।
4. ट्रैकिंग कोड को वेरीफाई करें
कोड जोड़ने के बाद यह सुनिश्चित करें कि यह सही तरीके से काम कर रहा है:
- Google Tag Assistant (एक Chrome एक्सटेंशन) का उपयोग करें यह जांचने के लिए कि कोड सही से इंस्टॉल हुआ है या नहीं।
- Google Analytics में Real-Time रिपोर्ट में जाकर लाइव डेटा देखें।
5. ट्रैकिंग का परीक्षण करें
सुनिश्चित करें कि आप अपनी वेबसाइट पर विभिन्न डिवाइस से विज़िट करें और देखें कि विज़िट्स ट्रैकिंग टूल में लॉग हो रही हैं या नहीं।