How to add new property in google analytics
To add a new property in Google Analytics, follow these steps:
Method 1: Using the Google Analytics Web Interface
- Sign in to your Google Analytics account.
- Click on the "Admin" button in the bottom left corner of the screen.
- Click on "Create Property" from the dropdown menu.
- Select "Web" as the property type (or "Mobile" or "App" if applicable).
- Enter the property name and URL.
- Choose the industry category and reporting timezone.
- Click "Create" to create the new property.
Method 2: Using the Google Analytics API
- Create a new project in the Google Cloud Console.
- Enable the Google Analytics API.
- Create a new service account and generate a private key file.
- Install the Google Analytics API client library for your preferred programming language.
- Use the client library to create a new property using the
analytics.management.properties.insert
method.
Here is an example of how to create a new property using the Google Analytics API in Python:
import os
import json
from google.oauth2 import service_account
from googleapiclient.discovery import build
# Replace with your own values
PROPERTY_NAME = 'My New Property'
PROPERTY_URL = 'https://example.com'
# Authenticate with the Google Analytics API
creds = service_account.Credentials.from_service_account_file(
'path/to/private/key.json',
scopes=['https://www.googleapis.com/auth/analytics']
)
# Create the Google Analytics API client
analytics = build('analytics', 'v3', credentials=creds)
# Create the new property
property_body = {
'name': PROPERTY_NAME,
'websiteUrl': PROPERTY_URL,
'industryCategory': 'Retail',
'timezone': 'America/New_York'
}
property = analytics.management().properties().insert(
body=property_body
).execute()
print('Property created:', property.get('id'))
Method 3: Using the Google Analytics Tag Assistant
- Install the Google Analytics Tag Assistant extension in your browser.
- Open the extension and click on the "Create Property" button.
- Enter the property name and URL.
- Choose the industry category and reporting timezone.
- Click "Create" to create the new property.
Note: The Tag Assistant is only available for Chrome and Firefox browsers.
After creating a new property, you can add tracking codes to your website or app to start collecting data.