Activity tags are snippets of JavaScript code that contain an HTML <img>
tag. The image tag sends a request to Ad Manager and records an activity event.
You can use Ad Manager reporting to understand conversion metrics for activity groups and activities. The raw key-values passed into these tags are available through Data Transfer.
Generate and place tags for activities
- Sign in to Google Ad Manager.
- Click Admin Activity groups.
- Click the activity group that contains the activity.
- Locate the activity and click Copy tag in the "Tag" column.
You can also copy activity tags when you click the activity details.
Add the activity tag to your website
- (Optional) If your tag relies on user information, modify the code to input the dynamically created values.
- Place activity tags near the
<body>
tag of the webpage where a visit represents the completed action you want to track.Example
If your website has a shop, you may want to track the number of completed purchases. You can track the purchases by placing the activity tag in the code for the purchase confirmation page. If you'd rather track visits to a user's shopping cart, place an activity tag in the code for the shopping cart webpage.
Understand the activity tag code
Let's look at some example activity tags to understand how they're put together. The tags differ slightly depending on the activity type.
Page views (Counter)The "Page views (Counter)" activity type tracks conversions for each time a user views a webpage.
Example
<img src="https://pubads.g.doubleclick.net/activity;xsp=1234;ord='+ a +'?" width=1 height=1 border=0/>
Let's look at the activity tag part by part.
img src
: An HTML image tag. The src
parameter tells the browser where to find the requested content for the image.
pubads.g.doubleclick.net
: The web address of the Ad Manager servers for conversion tracking.
activity
: Identifies the tag as an activity tag.
xsp=1234
: Identifies the activity. Each activity has its own unique ID.
ord='+ a +'
: A random number generator. The random number makes the tag unique each time it's served, which means that the user's browser can't serve it from the cache, but instead needs to make a fresh call to Ad Manager servers. That ensures that Ad Manager is able to check each page view for a conversion.
In the version of the image tag that's within the <noscript>
tags, the value for ord=
is set to 1
. That's because no value can be added dynamically. The <noscript>
version of the activity tag is served only to users whose browsers don't support JavaScript, which is a very small percentage of users.
width=1 height=1
: Sets the dimensions of the invisible image, in pixels.
border=0
: Sets the border of the image to 0 pixels so that it doesn't show.
The "Daily visits (Counter)" activity type tracks conversions for visits to a webpage, but only counts one conversion per user per day, even if a user visits the page multiple times.
Example
<img src="https://pubads.g.doubleclick.net/activity;xsp=1234;ord=1;num='+ a +'?" width=1 height=1 border=0/>
The tag is identical to a "Page visits (Counter)" tag, except for two key-values.
ord=1
: A random number generator.
num='+ a +'
: A random number generator. The random number makes the tag unique each time it's served, which means that the user's browser can't serve it from the cache, but instead needs to make a fresh call to the Ad Manager servers. That ensures that Ad Manager is able to check each page view for a conversion.
width=1 height=1
: Sets the dimensions of the invisible image, in pixels.
border=0
: Sets the border of the image to 0 pixels so that it doesn't show.
The "Custom (Counter)" activity type tracks conversions for visits to a webpage, but only counts one conversion per user per user session.
Session length is set by the advertiser, using the value of the ord=
key-value to insert a session ID. It's up to the advertiser to set and insert the session ID when the webpage containing the tag is loaded.
Ad Manager can only consider a session ID unique within a 24-hour day, starting at midnight Eastern Time. Even if the same session ID is used on subsequent days, a new conversion will be counted for each day.
Example
<img src="https://pubads.g.doubleclick.net/activity;xsp=1234;ord=[session id]?" width=1 height=1 border=0/
The "Items Purchased (Sales)" activity type is used to track conversions where the user has made a purchase. Specifically, it tracks the monetary value of each purchase, plus the number of items that were purchased and the order ID. It's up to the advertiser to insert these values dynamically when the webpage containing the tag is loaded.
The quantity, cost and order ID values passed into these tags are available through Data Transfer. The aggregated revenue totals for each activity are available through the Conversions metrics in Ad Manager reporting.
Example
<img src="https://pubads.g.doubleclick.net/activity;xsp=9659;qty=[quantity of items purchased];cost=[revenue];ord=[order id]?" width=1 height=1 border=0/>
Here are the elements that are unique to "Items Purchased (Sales)" activities:
qty=[quantity of items purchased]
: The number of items purchased in each order. For example, if a user buys three books as one purchase, the value 3
can be dynamically inserted.
cost=[Revenue]
: The amount of revenue generated by the entire transaction. The advertiser is responsible for dynamically inserting the value of each purchase. The value should be inserted as a number with a decimal, without commas or currency symbols.
The value of the cost parameter is interpreted to be in the same currency as the Ad Manager network.
ord=[orderID]
: The advertiser is responsible for inserting a unique identifier for each transaction.
The "Transactions (Sales)" activity type is used to track conversions where the user has made a purchase. Specifically, it tracks the monetary value of each purchase, plus the order ID. It's up to the advertiser to insert these values dynamically when the webpage containing the tag is loaded.
The quantity, cost and order ID values passed into these tags are available through Data Transfer. The aggregated revenue totals for each activity are available through the Conversions metrics in Ad Manager reporting.
Example
<img src="https://pubads.g.doubleclick.net/activity;xsp=10139;qty=1;cost=[revenue];ord=[order id]?" width=1 height=1 border=0/>
"Transactions (Sales)" activity tags are the same as "Items Purchased (Sales)" activity tags, with one exception:
qty=1
: This value is set to 1 because it's used to count the number of transactions. The number of transactions for a "Transactions (Sales)" activity is the same as the number of conversions.
Modify activity tags
If you're dynamically inserting key-values into an activity tag, such as an order number or a session ID, make sure to make any necessary changes to the tag to complete that process. It's up to you, as the advertiser, to implement any dynamic key-value insertions.
Example
If you create a 'Transaction (Sales)' tag in the following format:
<img src="https://pubads.g.doubleclick.net/activity;xsp=9659;
qty=[quantity of items purchased];
cost=[revenue];
ord=[order id]?"
width=1 height=1 border=0/>
You must replace [quantity of items purchased]
, [revenue]
, and[order id]
with code snippets that allow those values to be inserted dynamically when the webpage is loaded.
Do activity tags affect page load times?
On their own, activity tags have a minimal effect on the layout of webpages and the speed with which they're displayed. Additionally, a webpage containing an activity tag loads correctly even if the user's browser is unable to download the activity tag content.
The typical response time for pubads.g.doubleclick.net
calls is around 150-300 milliseconds, but we can't guarantee these times.
Best practices
We recommend that you place the tag code at the top of your webpage code, as close to the <body>
tag as possible. This ensures that a visit is counted even if the user closes the browser tab or otherwise stops the page from loading fully.
Also, ensure the HTTP call matches the security setting of the webpage where it's implemented (http://
for standard pages, https://
for secure pages).