How to integrate Google analytics in my website

how would you setup a google analytics account for your website and how to create google analytics code for my website
DavyGodwin Profile Pic
DavyGodwin,United States,Professional
Published Date:03-08-2017
Your Website URL(Optional)
Comment
LESSON 2 Creating a Google Analytics Account In this lesson, you learn how to sign up for Google Analytics. Creating a Google Account Before you can sign up for Google Analytics, you must have a Google account. If you use Gmail, Google Calendar, Google Docs, or similar Google applications, you already have a Google account and can use that account to sign up for Google Analytics. Likewise, if you subscribe to Google’s AdSense or AdWords programs, you can use that account to sign up for Google Analytics. NOTE: Google Account Singing up for a Google account is free. You can then use the same username (your email address) and password to access all of Google’s services. If you do not use any of Google’s services, however, you need to create a new Google account. Follow these steps: 1. Go to the Google Analytics main page (www.google.com/ analytics/), shown in Figure 2.1, and click the Sign Up Now link. 2. When the Create an Account page appears, as shown in Figure 2.2, enter your email address into the Your Current Email Address box. 3. Create a password and enter it into the Choose a Password box; then enter it again into the Re-Enter Password box.10 LESSON 2: Creating a Google Analytics Account FIGURE 2.1 The Google Analytics main page—before you sign up or sign in. FIGURE 2.2 Creating a new Google account. 4. Select your location from the Location pull-down list. 5. Enter your birthday into the Birthday box.Signing Up for Google Analytics 11 6. Enter the “secret word” into the Word Verification box. 7. Click the I Accept. Create My Account button. You are now prompted to create your Google Analytics account, which we discuss in the following section. Signing Up for Google Analytics Once you’ve created a Google account, you can then sign up for the Google Analytics program. We’ll show how to do this from the main Google Analytics page. Follow these steps: NOTE: Continuous Signup If you’re signing up for Google Analytics at the same time you’re creating a Google account, go directly to Step 4 after creating your Google account. 1. Go to the Google Analytics main page (www.google.com/ analytics/) and click the Sign Up Now link. 2. When the next page appears, enter your Google account email address and password; then click the Sign In button. 3. When the Getting Started page appears, click the Sign Up button. 4. You now see the General Information page, shown in Figure 2.3. Enter the URL for your site’s home page into the Website’s URL box. FIGURE 2.3 Entering information about your website.12 LESSON 2: Creating a Google Analytics Account NOTE: Secure Sites If your site is a secure site, pull down the list and select https:// instead of the default http://. 5. Enter a name for this website into the Account Name box. NOTE: Account Name You should select an account name that helps you identify this site if you plan on tracking multiple sites with Google Analytics—the domain name or home page URL, the internal name you give to the site, or something similar. 6. Select your country from the Time Zone Country or Territory pull-down list. 7. Select your time zone from the Time Zone pull-down list. 8. Click the Continue button. 9. When the Contact Information page appears, as shown in Figure 2.4, enter your first name and last name into the appropriate boxes. FIGURE 2.4 Entering your contact information. 10. Select your country (again) from the Country or Territory pull- down list. 11. Click the Continue button.Summary 13 12. When the Accept User Agreement page appears, read the terms of service and check the Yes option. 13. Click the Create New Account button. 14. Google now displays the tracking code you need to add to your website, as shown in Figure 2.5. You should copy and paste this code as detailed in Lesson 3, “Adding Google Analytics to Your Website.” FIGURE 2.5 Copy this tracking code to your website’s HTML. 15. After you’ve copied the tracking code, click the Save and Finish button. Summary In this lesson, you learned how to sign up for Google Analytics. In the next lesson, you learn how to add the Google Analytics tracking code to your website. www.allitebooks.com This page intentionally left blank LESSON 3 Adding Google Analytics to Your Website In this lesson, you learn how to configure your website for monitoring with Google Analytics. Adding Your Website to Google Analytics As you learned in Lesson 2, “Creating a Google Analytics Account,” Google asks you questions about your website during the initial signup process and then generates a piece of tracking code for you to paste into your website’s underlying HTML. We’ll review that process here, starting with your clicking the Sign Up button. 1. From the General Information page, shown in Figure 3.1, enter the URL for your site’s home page into the Website’s URL box. 2. Enter a name for this website into the Account Name box. 3. Select your country from the Time Zone Country or Territory pull-down list. 4. Select your time zone from the Time Zone pull-down list. 5. Click the Continue button. 6. When the Contact Information page appears, enter your first name and last name into the appropriate boxes.16 LESSON 3: Adding Google Analytics to Your Website FIGURE 3.1 Entering information about your website. 7. Select your country (again) from the Country or Territory pull- down list. 8. Click the Continue button. 9. When the Accept User Agreement page appears, read the terms of service and check the Yes option. 10. By default, Google shares your site’s analytics data with AdWords, AdSense, and other Google products, as well as anonymously with Google and other sites for benchmarking ser- vices. If you do not want to share your data, click the Edit Settings link in the Data Sharing Settings section; then uncheck the two sharing options. 11. Click the Create New Account button. 12. When the next page appears, as shown in Figure 3.2, select what you want to track: a single domain (that is, a single website), one domain with multiple subdomains, or multiple top-level domains. 13. If you also want to track AdWords advertising campaigns, check the I Want to Track AdWords Campaigns option. 14. Google now displays the tracking code you need to add to your website. Highlight and copy this tracking code. 15. Click the Save and Finish button. Adding Google Analytics Code to Your Website 17 FIGURE 3.2 Copy this tracking code to your website’s HTML. Adding Google Analytics Code to Your Website The tracking code generated by Google Analytics is a piece of JavaScript that looks something like this: script type=”text/javascript” var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”); document.write(unescape(“%3Cscript src=’” + gaJsHost + “google- analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”)); /script script type=”text/javascript” try var pageTracker = _gat._getTracker(“UA-xxxxxx-x”); pageTracker._trackPageview(); catch(err) /script As you can see, this code is actually two separate scripts. For your specific code, the “xxxxxx-x” is replaced with your own Google Analytics account number.18 LESSON 3: Adding Google Analytics to Your Website Once you’ve copied the tracking code generated by Google Analytics, you need to paste that code into your website’s underlying source code. You need to paste this code into every page on your site that you want to track. The tracking code should be inserted at the end of your page’s BODY section, just before the /BODY closing tag. Follow these steps: 1. Open the web page in a website editing tool, and enable HTML editing, as opposed to “what you see is what you get” (WYSIWIG) editing. 2. Scroll to the bottom of the document, to the end of the BODY section. 3. Paste the Google Analytics copy code just before the /BODY tag. 4. Save your web page. NOTE: Dynamic Websites For database-driven dynamic websites, you should insert the track- ing code on your index.php or equivalent page. Tracking Blog Performance You can also use Google Analytics to track performance of a blog. Simply treat your blog as a normal web page when creating a new Google Analytics profile; enter the blog’s URL when asked for the website URL. When Google Analytics generates the tracking code, enter that code into the underlying HTML for the bottom of the blog’s main page. This process differs from blog host to blog host. If your blog is hosted by Blogger, here’s how it works: 1. After you’ve generated and copied the Google Analytics tracking code, open your Blogger Dashboard (www.blogger.com), shown in Figure 3.3, and click the Layout link for the blog you want to track. 2. When the Layout page appears, scroll down to the bottom of the page and click the Add a Gadget link beneath the blog postings, as shown in Figure 3.4.Tracking Blog Performance 19 FIGURE 3.3 Editing a blog from the Blogger Dashboard. FIGURE 3.4 Add a new gadget to the bottom of your blog.20 LESSON 3: Adding Google Analytics to Your Website CAUTION: No Sidebar Gadgets Do not add the tracking code to a sidebar gadget. It must be added to a gadget in the footer of the blog. 3. When the Add a Gadget window appears, as shown in Figure 3.5, click the + for the HTML/JavaScript item. FIGURE 3.5 Add an HTML/JavaScript gadget. 4. When the Configure HTML/JavaScript window appears, as shown in Figure 3.6, make sure the Title box is left blank; then paste the copied tracking code into the Content box. 5. Click the Save button. NOTE: Using Blogger Learn more about Blogger blogs in my companion book, Using Blogger (Michael Miller, Que, 2010).Regenerating the Tracking Code 21 FIGURE 3.6 Paste the Google Analytics tracking code into this window. Regenerating the Tracking Code What if you don’t copy the tracking code when it’s first generated? Fortunately, Google allows you to regenerate the tracking code at any time, when it’s more convenient for you to paste into your website. To regenerate the tracking code, follow these steps: 1. Log onto Google Analytics to view the Overview page, shown in Figure 3.7. 2. Identify the website you want, and click that site’s Edit link in the Actions column. 3. When the Profile Settings page appears, as shown in Figure 3.8, click the Check Status link at the top right of the page. 4. Google now displays the tracking code for this site. Copy and paste this code into your site’s home page, as previously discussed.22 LESSON 3: Adding Google Analytics to Your Website FIGURE 3.7 The Google Analytics Overview page; click the Edit link for the site you want. FIGURE 3.8 Click the Check Status link to regenerate the site’s tracking code. Adding Another Website to Google Analytics You can track more than one website in your Google Analytics account— up to 50 sites, in fact. Each site you track is listed on your Overview page.Adding Another Website to Google Analytics 23 To add another website to your account, follow these steps: 1. From the Google Analytics Overview page, click the Add New Profile link. 2. When the Create New Website Profile page appears, as shown in Figure 3.9, check the Add a Profile for a New Domain link. FIGURE 3.9 Adding a new website to your Google Analytics profile. 3. Enter the URL for your site into the appropriate box. NOTE: Secure Sites If your site is a secure site, pull down the list and select https:// instead of the default http://. 4. Select your country from the Time Zone Country or Territory pull-down list. 5. Select your time zone from the Time Zone pull-down list. 6. Click the Continue button. 7. When the next page appears, select what you want to track: a sin- gle domain, one domain with multiple subdomains, or multiple top-level domains. www.allitebooks.com 24 LESSON 3: Adding Google Analytics to Your Website 8. If you also want to track AdWords advertising campaigns, check the I Want to Track AdWords Campaigns option. 9. Google now displays the tracking code you need to add to your website. Copy and paste this code into your site’s home page, as discussed previously in this lesson. 10. Click the Save and Finish button. Summary In this lesson, you learned how to add the Google Analytics tracking code to your website. In the next lesson, you learn how to use the Google Analytics Dashboard to learn more about your site’s performance.

Advise: Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.