Skip to main content
Solved

Problem with in-app and GTM

  • October 8, 2024
  • 5 replies
  • 110 views

Hi guys! I'm having trouble since the past week trying to set up the in-app functionality. My process is stuck at stage 2 of the initial configuration when you hace to choose your channels. The snippet is correctly installed (I can see it is fired on every page in debug mode) but Customer.io doesn't recognize it. I tried this 2 snippets:

1- This one is from the documentation page 

 !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="https://cdp.customer.io/v1/analytics-js/snippet/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._writeKey=key;analytics._loadOptions=e};analytics.SNIPPET_VERSION="4.15.3";
 analytics.load(
     "YOUR_API_KEY",
     { 
         "integrations": {
             "Customer.io In-App Plugin": { 
                 siteId: "YOUR_SITE_ID"
             }
         }
     }
 );
 analytics.page();
 }}();

2- And this one is from the sources page

<script>
  !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="https://cdp-eu.customer.io/v1/analytics-js/snippet/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._writeKey=key;analytics._loadOptions=e};analytics.SNIPPET_VERSION="4.15.3";
    analytics.load("MY API KEY");
    analytics.page();
  }}();
</script>

Had anyone a similar problem? I don't know what else to try.

Best answer by sbattista

I solved the problem with Byron’s help. I used the classic Customer.io snippet instead Javascript one, and that works perfect.

View original
Did this topic help you find an answer to your question?

5 replies

Byron
  • 69 replies
  • October 9, 2024

Hi Sebastian,

Byron here from the technical support team. I understand you’re trying to implement our in-app messaging feature on your website via GTM, is that right? In the info you provided above, the first script would be the one you want to use, which has the in-app messaging feature plugin enabled with the snippet below

analytics.load( "YOUR_API_KEY", { "integrations": { "Customer.io In-App Plugin": { siteId: "YOUR_SITE_ID" } } } );

 

This script works for our JS Source in Pipelines. Do you have the JS Source set up and enabled in CDP? If so, you’ll also want to verify you’re using the correct API key (For the JS Source, not for your Journeys workspace) and Site ID (this is the same for Pipelines and Journeys).

 

Are you seeing any errors on the page or in the script? 


  • Author
  • Novice
  • 4 replies
  • October 9, 2024

Hi Byron. Thanks for your answer. I changed the tag to the one you told me but still not work. I checked both site ID and API key and I’m using the correct ones.

The tag fires well on my pages and doesn’t have an error nor in Customer.io or GTM. This is driving me crazy haha.


Byron
  • 69 replies
  • October 9, 2024

Hello,

Can you also confirm that your site is identifying people?

https://customer.io/docs/cdp/sources/connections/javascript/js-source/#identifying-users

 

When you’re logged into your site, if you can open the Application tab and view Cookies, you should see ajs_user_id cookie that will contain the identifier (more info here: https://customer.io/docs/cdp/sources/connections/javascript/js-source-cookies/)

 

You’ll then want to use that identifier to try to send a test in-app message -- I would try even if the UI shows that your app is not connected.

 

Can you also confirm that your JS source in Pipelines is showing activity in the data-in tab?


  • Author
  • Novice
  • 4 replies
  • October 9, 2024

Hi Byron. I can see the cookie with that name but that id doesn’t correspond to any user.

In Customer.io dashboard, my user has this data

And, as you can see, the app is populating data.

 


  • Author
  • Novice
  • 4 replies
  • Answer
  • October 16, 2024

I solved the problem with Byron’s help. I used the classic Customer.io snippet instead Javascript one, and that works perfect.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings