Digital Marketing Solutions Solutions and Services Web Analytics Solutions

How to copy custom dimensions to another property (Google Analytics)

Last Updated on October 5, 2021 by Shivanandana Hegde

Google Analytics copy custom dimension  - GA Logo
Google Analytics – Custom Dimension – Copy using API

In this article, Firstly, I will explain how to copy custom dimensions in Google Analytics from one property to another property. Secondly, the best part is that, it can be used for multiple properties using a simple technique.

If you want to copy custom dimensions from one property to another, it can be done manually. However, for multiple properties, the manual process consumes a lot of time and effort. So, this method automates it and creates more efficiency.

Pre-Requisites for Copying Custom Dimensions in Google Analytics

  1. Google Universal Analytics Account:- You must have admin access for the Google Analytics account.
  2. Gmail Account:- Make sure that you have a Gmail ID through which you can access Google Analytics.
  3. Custom Dimensions:- At lease one of the property in your Google Analytics account should have the custom dimensions already created.
  4. Source Account ID and Property ID:- Account and Property ID refers to the IDs where the custom dimensions are already present.
  5. Destination Account ID and Property IDs:- This is nothing but the ID of the account and properties where you want to copy the dimensions.

Below are 4 simple steps to copy custom dimensions

Lets deep dive into how we can achieve this. Moreover, all you need is to follow few simple steps and we are good to go!

Step 1: Create a Project in Google Script. (It’s Free)

Visit and click on “Start Scripting” as shown below.

Google App Script - Link - To copy custom dimensions

Once you click on “Start Scripting” you must Sign In using the Gmail account.

Please note that the Google Analytics account should be linked with the Gmail ID.

Upon successful login , you will land on the Google Script Home Page. Click on “New Project”.

Google App Script Home Page

Step 2: Rename the project and add Google Analytics API as a Service.

Now click on Untitled Project and rename it as “Google Analytics Copy Dimensions”.

Rename Project before copying custom dimensions

Once it is renamed, click on “+” icon beside the “Services” Menu as shown in above screenshot and select “Google Analytics API” and click “Add”.

Add Google Analytics API Service

We are now ready to add the actual logic/code to copy custom dimensions.

Step 3 to Copy Custom Dimensions: Add Google Script Code.

Add the below code into the code editor where you have created the project.

function copyDimensions() {
  var gaSourceProperty = 'UA-XXXXXX-1'
  var gaSourceAccount = 'Source account ID goes here'
  var sourceDimensions = Analytics.Management.CustomDimensions.list(gaSourceAccount, gaSourceProperty)
  var items = sourceDimensions['items']
  var gaDestinationProperty = ['UA-XXXXXX-1','UA-XXXXXX-2','UA-XXXXXX-3','UA-XXXXXX-4']
  var gaDestinationAccount = 'Destination Account ID goes here' 
  for(var j=0; j<gaDestinationProperty.length; j++){
  for (var i = 0; i<items.length; i++){
    var resource = {'name':items[i]['name'],'scope':items[i]['scope'],'active':items[i]['active']}
    Analytics.Management.CustomDimensions.insert(resource, gaDestinationAccount, gaDestinationProperty[j])

Understanding of the Logic part

  • gaSourceProperty” variable is the Property ID of the Google Analytics account where you have already created the custom dimensions.
  • gaSourceAccount” variable is the Account ID of the Google Analytics account where you have already created custom dimensions.
  • gaDestinationProperty” variable consists of an array of properties where you wanna copy those custom dimensions.
  • gaDestinationAccount” variable holds the value of Account ID where yu want to copy the custom dimensions.

You can obtain these values from Google Analytics Admin Section. Please ensure that the Property and Account ID are correct. Else , you will end up getting the error while running the code.

Google Analytics Account and Property ID for copying custom dimensions
  • The variable “sourceDimensions” will hold the list of Dimensions from the source property.
  • The variable “resource” holds name, scope and active status of the custom dimensions as shown below.
Google Analytics Custom Dimensions
  • The “insert” function inserts the custom dimensions into the required set of properties.
  • Utilities.sleep(1000) ensures that there is a sufficient time to create dimensions before moving to the next property.

Step 4: Save and Run the Code.

Once you have modified the Account ID and Property ID details in the code, click on Save icon.

Google App Script Save and Deploy

Now , Click on “Run”. If it asks for Permission, click on “Review Permission” and allow access.

Google App Script Review Permissions

As a result, you will see the Execution Log with a success message.

VOILA!!!! ? You have successfully copied the Custom Dimensions into required properties.

In conclusion:

  • This code works only for Google Universal Analytics property. However, it won’t work on GA4 properties as of today.
  • This code best suits when there are multiple properties under a single account.

If you want to learn how to install Analytics on your website, here is the link:-

You can learn more about Google Analytics API using Google Script here:-

Like Reading Smart Content?

Join hundreds of Smart Readers.

* Only new post notifications.
* No promotions, No spams whatsoever.

We don’t spam! Read our privacy policy for more info.

Leave a Reply

Your email address will not be published. Required fields are marked *


Get notified on new posts.

Choose your preferences

No Spams whatsoever. Digilitica will never share your personal data with any third party.
Read our Privacy Policy.