Narrativ Brand Tag¶
What is it?¶
The Narrativ Brand Tag is a lightweight javascript tag that enables partners to maximize their performance and unlock valuable article and product level insights in a customized dashboard. Only clients with Narrativ’s Brand Tag can optimize their campaigns by ROAS and see more comprehensive metrics like revenue and RPC.
Please note: data collection by the brand tag does not contain personally identifiable information (PII) and is in compliance with GDPR and CCPA.
How it Works¶
The Narrativ Brand Tag is responsible for handling two types of events: page impressions and checkouts.
Page Impressions¶
Page impression events enable Narrativ to ensure attribution for our partners. These events should be fired on every page that doesn’t contain PII.
Checkouts¶
Checkout events allow Narrativ to accurately capture revenue and conversions in real time. The data gathered by checkout events also powers an experience publishers rely on to track top sellers and give better product recommendations on their articles.
Checkout events should be fired on your site’s Order Confirmation Page, or the page that loads immediately after they’ve successfully purchased their items.
Please note: Similar to Page Impression, Checkouts are in compliance with GDPR and CCPA and does not capture personally identifiable information (PII). Additionally, since the tag runs asynchronously in the background, there is no impact to the page load time.
Implementation¶
Page Impression Events¶
Getting the Narrativ Brand Tag to fire page impression events is a simple process. Copy and paste the following Javascript snippet in the HEAD section of all your site’s pages that don’t contain PII.
Make sure to replace
ACCOUNT NAME
with your Narrativ account name.Need your Narrativ account name? Reach out to your growth manager or solutions@narrativ.com for assistance.
<script type="text/javascript">
(function(account) {
try {
var b = document.createElement("script");
b.type = "text/javascript";
b.src = "https://static.narrativ.com/tags/" + account + ".js";
b.async = true;
var a = document.getElementsByTagName("script")[0];
a.parentNode.insertBefore(b, a);
} catch (e) {}
}("ACCOUNT NAME"));
</script>
Checkout Events¶
In order to successfully fire checkout events with the Narrativ Brand Tag, the following code snippet must be populated with information about the checkout, along with a few details about each of the products purchased. This snippet should be placed on your site’s Order Confirmation Page, or the page displayed to customers immediately after they’ve successfully purchased their items.
Make the Checkout Event Code Work for You¶
Follow the sample code below, making these changes:
Statement |
Requirement |
Data Type |
Notes |
---|---|---|---|
|
Replace |
Object |
|
|
Replace |
String |
|
|
Replace |
String |
|
|
Replace |
String |
Both cart level and product level coupon codes should be captured in this variable (e.g. if a coupon code variable in the data layer is not null, apply X% discount to product_price) |
|
Replace |
Integer |
|
|
Replace |
String |
If Item Brand is not available, replace |
|
Replace |
String |
If Item Size is not available, replace |
|
Replace |
String |
If Item Color is not available, replace |
|
Replace |
String |
|
|
Replace |
Boolean |
If this is not available, replace |
|
Replace |
String |
|
|
Replace |
String |
Note: Remember to also replace ACCOUNT NAME
with your Narrativ account name.
<script type="text/javascript">
var purchased = <dataLayerProducts>;
var productsPurchased = [];
var orderTotal = 0;
for (var i = 0; i < purchased.length; i++) {
productsPurchased.push({
product_id: purchased[i].<ItemID>,
product_name: purchased[i].<ItemName>,
product_brand: purchased[i].<ItemBrand>,
product_size: purchased[i].<ItemSize>,
product_color: purchased[i].<ItemColor>,
product_price: purchased[i].<ItemPrice>,
product_quantity: purchased[i].<ItemQuantity>,
});
orderTotal += (purchased[i].<ItemPrice> * purchased[i].<ItemQuantity>);
}
window.BAMX_EVENT_DATA = {
page_type: 'checkout',
is_new_visitor: <IsNewVisitor>,
products_purchased: productsPurchased,
order_id: <OrderID>,
order_value: orderTotal,
currency: <CurrencyCode>,
};
(function(account) {
try {
var b = document.createElement("script");
b.type = "text/javascript";
b.src = "https://static.narrativ.com/tags/" + account + ".js";
b.async = true;
var a = document.getElementsByTagName("script")[0];
a.parentNode.insertBefore(b, a);
} catch (e) {}
}("ACCOUNT NAME"));
</script>
Shopify Checkout Code¶
Please use the script tag below in place of the previous checkout code if you prefer to implement through an existing Shopify integration:
<script type="text/javascript">
if(Shopify.Checkout.step == ‘thank_you’){
var productsPurchased = [
{% for line_item in checkout.line_items %}
{% if line_item.price > 0 %}
{
“product_id” : “{{ line_item.product_id }}”,
“product_name” : “{{ line_item.product_title | capitalize }} {% if
line_item.product.metafields.c_f.tagline %}
{{ line_item.product_metafields.c_f.tagline }}{% endif %}”,
"product_brand":"{{ line_item.product.vendor }}",
"product_size":"{{ line_item.variant.option1 }}",
"product_price" : "{{ line_item.price | money_without_currency }}",
"product_quantity" : "{{ line_item.quantity }}", },
{% endif %}
{% endfor %} ];
window.BAMX_EVENT_DATA = {
"page_type": “checkout”,
"is_new_visitor": "{{customer.has_account}}",
"products_purchased": productsPurchased,
"order_id": Shopify.checkout.order_id.toString() || "{{order_number}}",
"order_value": Shopify.checkout.subtotal_price || "{{subtotal_price | money_without_currency }}",
"currency": Shopify.checkout.currency || "{{currency.iso_code}}",
};
(function(account) {
try {
var b = document.createElement("script");
b.type = "text/javascript";
b.src = "https://static.narrativ.com/tags/" + account + ".js";
b.async = true;
var a = document.getElementsByTagName("script")[0];
a.parentNode.insertBefore(b, a);
} catch (e) {}
}("ACCOUNT NAME"));
</script>
Note: Remember to also replace ACCOUNT NAME
with your Narrativ account name.
Google Tag Manager Implementation¶
Implementing the Narrativ Brand Tag with Google Tag Manager is a simple process. Follow the instructions below to implement the tag using a “Custom HTML” tag in GTM.
Page Impression Events¶
Start by navigating to your Google Tag Manager Dashboard.
Select the “Tags” menu item from the menu on the left-hand side of the page.
Once on the “Tags” page, select the “New” button to create a new tag.
Select the “Tag Configuration” box to begin making a new tag.

Select the “Custom HTML” option to open an empty text field.

Copy and paste the code outlined in the above section entitled “Page Impression Events: Implementation”. Make sure you replace
ACCOUNT NAME
with your Narrativ account name.

Select “All Pages” as the correct trigger for these events.

Name the tag “Narrativ Page Impression Events” and double check that the trigger is set to “All Pages”.

Checkout Events¶
For checkout events, create a new tag and open the empty text field again.

Follow the instructions outlined in the “Checkout Events: Implementation” Section above to successfully fire checkout events.
Note: var purchased
should be set to the data layer variable corresponding to products purchased at checkout.
This can be defined independent of GTM variables (see previous screenshot), or it can be found in the
Variables section of your Tag Manager dashboard
GTM variables referenced in the checkout tag should be wrapped in doubly curly brackets.
Here is an example of the fully implemented checkout code:

Select the box under “Triggering” to add a trigger for this tag.

If you don’t already have a trigger for checkout pages, then it’s easy to create one!

The below example has a series of triggers based off of common URL types for checkout or confirmation pages. (E.g. narrativ.com/checkout/ will trigger the “Checkout Page” option). Replace “checkout” with whatever word your site uses on checkout pages. Remember, you only need one trigger!

Double check the tag name, make sure you’ve updated the code with the information on your checkout page, and make sure you’ve selected the correct trigger.

Publishing Tags¶
Make sure that the tag(s) are showing up in the “Tag” tab.

Preview the changes made and fix any errors that pop up in the window.

Click the “Submit” button to save your changes (this step is not final)

Double check that everything you modified is in this submission. Name the submission something like “Adding Narrativ Brand Tag” so that it’s easy to find if you need to go back and debug any issues in the future.

If you have any issues during this process then reach out to your Narrativ growth manager or email us at solutions@narrativ.com.
Testing the Brand Tag¶
Page Impressions¶
To test the page impression code, filter “bam” in Developer Tools and check for these three events on refresh:

Checkouts¶
Place a test order to QA the checkout tag. Similar to the page impression test, be sure to have “bam” filtered in Developer Tools before you place the order. On the confirmation page, you should see an additional checkout event firing:

When you navigate into the “Request Payload” within the checkout event, you should see information about the order and products purchased:

Please note: We recommend placing an additional test order with a coupon code to ensure order value and product price variables accurately capture any discounts.
If you have any issues during the implementation or testing process, please reach out to your Narrativ growth manager or email us at solutions@narrativ.com.