Content Tracking is not working?

Hello,

I have a problem with content tracking because I don’t get the data from the defined content blocks in reporting/analytics output.

I use the tag manager and I defined a matomo configuration where I enabled “Track All Content Impressions”.

I created a trigger of type custom event with a tag of type custom html with the following script:

<script>
  console.log('trackAllContentImpressions-Tag');
  _paq.push(['trackPageView']);
  _paq.push(['trackAllContentImpressions']);
  _paq.push(['logAllContentBlocksOnPage']);
</script>

I see the console log output and all the content blocks like this:

[
    {
        "name": "job-box-list",
        "piece": "job-list-item-9b64c1dd-3471-441e-b0f5-aeb35f5811c9",
        "target": "/stellenangebote/9b64c1dd-3471-441e-b0f5-aeb35f5811c9"
    },
    {
        "name": "job-box-list",
        "piece": "job-list-item-b97c5e1c-3296-4fa9-8512-59f8d46d3711",
        "target": "/stellenangebote/b97c5e1c-3296-4fa9-8512-59f8d46d3711"
    },
    {
        "name": "job-box-list",
        "piece": "job-list-item-48fd9ef9-7cb2-4eb4-80db-38c1e30d98f9",
        "target": "/stellenangebote/48fd9ef9-7cb2-4eb4-80db-38c1e30d98f9"
    },
    {
        "name": "job-box-list",
        "piece": "job-list-item-1697910b-8eb9-4b07-825f-c6bf4897cf78",
        "target": "/stellenangebote/1697910b-8eb9-4b07-825f-c6bf4897cf78"
    },
    {
        "name": "job-box-list",
        "piece": "job-list-item-7cc6a2ec-0d3b-4719-a76b-8e05e9787c1d",
        "target": "/stellenangebote/7cc6a2ec-0d3b-4719-a76b-8e05e9787c1d"
    },
    {
        "name": "pb-section-homepage-search-buttons",
        "piece": "button-iPark-Media GmbH",
        "target": "https://ipark-media.de"
    },
    {
        "name": "pb-section-homepage-search-buttons",
        "piece": "button-Promotion",
        "target": "https://ipark-media.de"
    },
    {
        "name": "pb-section-homepage-search-buttons",
        "piece": "button-Merchandising",
        "target": "https://ipark-media.de"
    },
    {
        "name": "pb-section-homepage-hero",
        "piece": "Section",
        "target": ""
    }
]

But I don’t see any data tracked as content impressions in the report. I tried multiple different variants and settings but I don’t get it.

Hope someone can help me to solve the problem!

Best regards,

Timo

The topic I found about content tracking: Content Tracking stops working when trackVisibleContentImpressions - Support & Bugs - Matomo forums
I hope it can help…

Thanks for your reply. I found this topic this morning but I think it’s more about trackContentImpressionsWithinNode.

In my case I tried to track trackAllContentImpressions but even this simplier way of tracking is not working.

Before any digging, can you confirm that a network request is being sent to your Matomo server with the relevant Content Tracking impressions? Have you tried other browsers? If you’re on version 4 of Matomo, did you enable Beacon (highly recommended)?

Hi Dane,

thanks for your reply.

I checked network an I see requests like this:

https://my-url/matomo.php?e_c=Ausgabe%20in%20Box&e_a=Ausgabe%20in%20Box%20XXX&e_n=%5Bobject%20Object%5D.name%20%2F%20%5Bobject%20Object%5D.id&e_v=4&ca=1&idsite=4&rec=1&r=125323&h=9&m=16&s=33&url=http%3A%2F%2Flocalhost%2Fhome&uid=c5b53ccc-d68d-4733-8933-0fd6c5838d06&_id=023d98fce3fc6344&_idn=0&_refts=0&send_image=0&pdf=1&qt=0&realp=0&wma=0&fla=0&java=0&ag=0&cookie=1&res=1820x1024&_pkc=Job%20in%20Box&_pks=5ab70e95-d162-45be-80ca-6828e92a46a0&_pkn=Ibiza%202020%20is%20calling.%20Who%20is%20in%3F&dimension1=true&pv_id=69kiLN

I don’t understand all parameters but it seems that the request for the content impression is sended.

Same issue in other browser (chrome and firefox).

I use Matomo Version 4.3.1. I now activate the “always use the sendBeacon”-option in configuration but I still see no content tracking.

Do you have any other ideas, for example other configurations I have to set?

Best regards,

Timo

The HTTP API : Tracking HTTP API: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v4 :wink:

(but sorry, I havn’t the answer to your issue)

Thanks for your reply.

With that I checked the network requests again and I can’t find any request with an c_n/c_p/c_t for content tracking in it. So it seems that there are no requests for content tracking.

What can be a reason for this?

I enabled “track all content impressions” in tag manager matomo configuration.

Are there any other options I have to activate or things I can check? I don’t know why there are no requests for content tracking.

Best regards,

Timo

I was going to say your sample request does not contain any Content Tracking data, but it looks like you figured that out.

For the sake of thoroughness, can you provide a sample content block? I want to see if you’re correctly using their data attributes or CSS class names. Based on the fact that you are logging the output and it looks good, the answer is probably a “yes,” but let’s be thorough. Also, these are blocks that exist on the page at the time you call trackAllContentImpressions? We want to eliminate the jankiness of the trackContentImpressionsWithinNode method.

Lastly, it reads like the requests for Content Tracking themselves are not being sent, so you see no requests at all with Content Tracking data, or you see the requests being sent but you don’t see the data logged in the Matomo UI? If the latter, can you confirm that your requests are successfully being delivered with a 2xx-level HTTP response code? By sending them via Beacon, you should the data being sent as POST and receive 204 response.

Hi Dane,

thanks for your reply!

Here are some parts of the code which contain the content tracking part:

<section id="pb-section-homepage-hero" data-track-content data-content-name="pb-section-homepage-hero" data-content-piece="Section" class="no-print"><div class="v-image v-responsive white--text theme--dark"

<div class="row"><div class="col text-center"><a href="[/jobs/suche-nach/Promotion](http://localhost:3000/jobs/suche-nach/Promotion)" data-track-content="" data-content-name="pb-section-homepage-search-buttons" data-content-piece="button-Merchandising" data-content-target="https://ipark-media.de" class="v-btn v-btn--outlined v-btn--router v-btn--tile theme--light v-size--default primaryYellow--text pb-carousel-button ma-1"><span class="v-btn__content"><!---->
Merchandising
</span></a><a href="[/jobs/suche?what=Promotion](http://localhost:3000/jobs/suche?what=Promotion)" data-track-content="" data-content-name="pb-section-homepage-search-buttons" data-content-piece="button-Promotion" data-content-target="https://ipark-media.de" class="v-btn v-btn--outlined v-btn--router v-btn--tile theme--light v-size--default primaryYellow--text pb-carousel-button ma-1"><span class="v-btn__content"><!---->
Promotion
</span></a><a href="[https://ipark-media.de](https://ipark-media.de/)" target="_blank" data-track-content="" data-content-name="pb-section-homepage-search-buttons" data-content-piece="button-iPark-Media GmbH" data-content-target="https://ipark-media.de" class="v-btn v-btn--outlined v-btn--tile theme--light v-size--x-large primaryYellow--text pb-carousel-button ma-1"><span class="v-btn__content"><!---->
iPark-Media GmbH
</span></a></div></div>

Also, these are blocks that exist on the page at the time you call trackAllContentImpressions ? We want to eliminate the jankiness of the trackContentImpressionsWithinNode method.

Thats a point I’m really unsure with, because the site is a spa with nuxt/vuejs. But I even tried to define the tag with a timeout like following code and its not working:

<script>
    setTimeout(() => {
      console.log('trackVisibleContentImpressions-Tag mit Timeout');
      _paq.push(['trackPageView']);
      _paq.push(['trackAllContentImpressions']);
      _paq.push(['logAllContentBlocksOnPage']);
    }, 5000);
</script>

For your last question: I searched in my network requests for c_ to find any request which contains any content tracking information but I did not find any request. So I see no request for content tracking at all.

Ah, okay, then I believe we may have found the problem. You’re attempting to track dynamically loaded content, but you’re not calling the method to do so.

To initiate Content Tracking, regardless of page type, there is that initial bit of boilerplate that needs to be executed, which you’re doing; you’ve currently got it within a timeout, but that’s unnecessary.

On a simple page that has all content available from the initial page loaded backend response, in combination with the data attributes added to the markup, you should start seeing tracked content impressions.

However, on a page that dynamically loads content, such as single page apps, you absolutely require calls to trackContentImpressionsWithinNode. The method itself is reliable as long as you use trackContentImpression and not trackVisibleContentImpressions in that boilerplate, which, again, you’re doing.

I’m not sure of the complexity of your page, but using the example markup provided, you would make a call similar to the below snippet after the boilerplate has been executed and only once you know the dynamic content has loaded, replacing syntax for targeting selectors in whatever framework or library you’re using. For the sake of context, I’m using the row class to find the node, but for your case you will need to determine the better selector to target, taking into account that because it’s a single page app, you may need a selector with much broader scope. Note that I’m also demonstrating this with jQuery, so again use what library you’re operating with:

var contentTrackingBlockNode = $('.row').get(0);
_paq.push(['trackContentImpressionsWithinNode', contentTrackingBlockNode]);

Note that the trackContentImpressionsWithinNode methods accepts a single DOM node, so do not attempt to pass it an array of nodes.

By the way, I’m not sure about the formatting of the markup in your example, as it’s a bit messed up and not wrapped correctly, but do keep in mind that you cannot nest content tracking blocks, so if you’re actually using the <section> tag as a parent to the formatting markup beneath it, that will not work and will need to be corrected, because that will also prevent Content Tracking from working correctly. If you want to convey hierarchy in your tracked content, you should settle on a naming convention to use for the data-content-name values, like data-content-name="pb-section-homepage-hero:row:link" or similar, thus eliminating the parent content block data attributes and just codifying it on the target blocks themselves.

Hi Dane,

thanks for your reply. I have to talk with a colleague about your feedback and how to implement it in the application.

My hope was that when trackAllContentImpressions is called at the right time (when everything is loaded) that it’s no matter if the content is dynamic or stratic.

Also I want to define the script for content tracking as tag in tag manager and not in application code. I’m not sure what’s a way to handle this and even if thats possible. Do you know if its possible (and a good approach) to handle something like

_paq.push(['trackAllContentImpressions']);
_paq.push(['trackContentImpressionsWithinNode', document.querySelector('#my-element')]);

in a tag?

Hi guys,

We had the same issue, the trigger does not feed back the information…

_paq.push(['trackAllContentImpressions']);
_paq.push(['trackContentImpressionsWithinNode', document.querySelector('#show-unsubscribe')]);

we track a vueJS modal, and the code is triggered when the modal is loaded.

There is something strange, it is when I change the size of the page, the resizing brings up the information

any ideas to fix that ?

Best Regards,

Pierre-Paul Quilichini