salmon-plastic-31303
11/10/2022, 8:12 PMgentle-petabyte-80785
11/11/2022, 10:41 AMsalmon-plastic-31303
11/11/2022, 10:42 AMgentle-petabyte-80785
11/11/2022, 10:48 AMgentle-petabyte-80785
11/11/2022, 10:49 AMmanualLoad
// Whether to completely skip calling.analytics.load()
// ADVANCED FEATURE: only use if you are callingmanuallyanalytics.load()
// elsewhere in your code or are using a library
// that will call it for you.
// Useful for only loading the tracking script once a user has opted in to being tracked, for example.
// *Another use case is if you want to add callbacks to the methods at load time.
gentle-petabyte-80785
11/11/2022, 10:49 AMmanualLoad: falsesalmon-plastic-31303
11/11/2022, 10:51 AMsalmon-plastic-31303
11/11/2022, 10:52 AMgentle-petabyte-80785
11/11/2022, 10:54 AMsalmon-plastic-31303
11/11/2022, 10:54 AM// your rudderstack write key for your production environment
// when process.env.NODE_ENV === 'production'
// required; non-empty string
//NOTE: Do not commit this to git. Process from env.
prodKey: `my key`,
// if you have a development env for your rudderstack account, paste that key here
// when process.env.NODE_ENV === 'development'
// optional; non-empty string
//NOTE: Do not commit this to git. Process from env.
devKey: `my key`,
// boolean (defaults to false) on whether you want
// to include analytics.page() automatically
// if false, see below on how to track pageviews manually
trackPage: true,
// number (defaults to 50); time to wait after a route update before it should
// track the page change, to implement this, make sure your `trackPage` property is set to `true`
trackPageDelay: 50,
// If you need to proxy events through a custom data plane,
// add a `dataPlaneUrl` property (defaults to https://hosted.rudderlabs.com )
// RudderStack docs:
// - https://docs.rudderstack.com/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk#3-1-load
// dataPlaneUrl: `https://override-rudderstack-endpoint`,
// Add a `controlPlaneUrl` property if you are self-hosting the Control Plane
// RudderStack docs:
// - https://docs.rudderstack.com/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk#3-1-1-self-hosted-control-plane
// controlPlaneUrl: `https://override-control-plane-url`,
// boolean (defaults to false); whether to delay load RudderStack
// ADVANCED FEATURE: only use if you leverage client-side routing (ie, Gatsby <Link>)
// This feature will force RudderStack to load _after_ either a page routing change
// or user scroll, or after `delayLoadTime` elapses, whichever comes first. This feature is used to help improve your website's
// TTI (for SEO, UX, etc). See links below for more info.
// NOTE: But if you are using server-side routing and enable this feature,
// RudderStack will never load (because although client-side routing does not do
// a full page refresh, server-side routing does, thereby preventing RudderStack
// from ever loading).
// See here for more context:
// GIF: https://github.com/benjaminhoffman/gatsby-plugin-segment/pull/19#issuecomment-559569483
// TTI: https://github.com/GoogleChrome/lighthouse/blob/master/docs/scoring.md#performance
// Problem/solution: https://marketingexamples.com/seo/performance
delayLoad: true,
// number (default to 1000); time to wait after the page loads
// to load the RudderStack SDK
// To be used when `delayLoad` is set to `true`
delayLoadTime: 2500,
// Whether to completely skip calling `analytics.load()`.
// ADVANCED FEATURE: only use if you are calling `analytics.load()` manually
// elsewhere in your code or are using a library
// that will call it for you.
// Useful for only loading the tracking script once a user has opted in to being tracked, for example.
// *Another use case is if you want to add callbacks to the methods at load time.
manualLoad: false,
// string ('async' or 'defer'); whether to load the RudderStack SDK async or defer. Anything else
// will load normally.
// 'async' will load the SDK as <script async></script>
// 'defer' will load the SDK as <script defer></script>
loadType: 'default',
// Options to the `load` API
// Note: The above `controlPlaneUrl` overrides the `configUrl` field in this object
// loadOptions: {
// }salmon-plastic-31303
11/11/2022, 10:56 AMsalmon-plastic-31303
11/11/2022, 10:56 AMsalmon-plastic-31303
11/11/2022, 10:58 AMsalmon-plastic-31303
11/11/2022, 10:58 AMsalmon-plastic-31303
11/11/2022, 11:00 AMwindow.rudderSnippetLoaded = false;
window.rudderSnippetLoading = false;
window.rudderSnippetLoadedCallback = undefined;
window.rudderSnippetLoader = function (callback) {
if (!window.rudderSnippetLoaded && !window.rudderSnippetLoading) {
window.rudderSnippetLoading = true;
function loader() {
window.rudderanalytics.load('removed', 'https://hosted.rudderlabs.com');
window.rudderSnippetLoading = false;
window.rudderSnippetLoaded = true;
if (callback) { callback(); }
if (window.rudderSnippetLoadedCallback) {
window.rudderSnippetLoadedCallback();
window.rudderSnippetLoadedCallback = undefined;
}
};
"requestIdleCallback" in window
? requestIdleCallback(function () { loader(); })
: loader();
}
}
window.addEventListener('scroll',function () {window.rudderSnippetLoader()}, { once: true });
setTimeout(
function () {
"requestIdleCallback" in window
? requestIdleCallback(function () { window.rudderSnippetLoader(); })
: window.rudderSnippetLoader();
},
8000 || 1000
);
rudderanalytics=window.rudderanalytics=[];for(var methods=["load","page","track","identify","alias","group","ready","reset","getAnonymousId","setAnonymousId"],i=0;i<methods.length;i++){var method=methods[i];rudderanalytics[method]=function(a){return function(){rudderanalytics.push([a].concat(Array.prototype.slice.call(arguments)))}}(method)}
;salmon-plastic-31303
11/11/2022, 11:00 AMgentle-petabyte-80785
11/11/2022, 11:06 AMdefer="" I'm not familiar with this type of declaration of defer. I have seen <script defer src=".... though
• I'm not familiar with RudderStack loadType config. I didn't find it in the docs heregentle-petabyte-80785
11/11/2022, 11:08 AMloadType config?salmon-plastic-31303
11/11/2022, 11:08 AMsalmon-plastic-31303
11/11/2022, 11:09 AMsalmon-plastic-31303
11/11/2022, 11:10 AMgentle-petabyte-80785
11/11/2022, 11:11 AMsalmon-plastic-31303
11/11/2022, 11:13 AMsalmon-plastic-31303
11/11/2022, 11:13 AMsalmon-plastic-31303
11/11/2022, 11:14 AMgentle-petabyte-80785
11/11/2022, 11:14 AMsalmon-plastic-31303
11/11/2022, 11:16 AMgentle-petabyte-80785
11/11/2022, 11:16 AMIdeally I’d like to load it at the end of the page load not the beginningThis must be happening with this code
gentle-petabyte-80785
11/11/2022, 11:16 AMsalmon-plastic-31303
11/11/2022, 11:17 AMsalmon-plastic-31303
11/11/2022, 11:17 AMsalmon-plastic-31303
11/11/2022, 11:17 AMsalmon-plastic-31303
11/11/2022, 11:18 AMsalmon-plastic-31303
11/11/2022, 11:19 AMsalmon-plastic-31303
11/11/2022, 11:21 AMsalmon-plastic-31303
11/11/2022, 11:22 AMgentle-petabyte-80785
11/11/2022, 11:27 AMdefer, it is the execution of the script that happens after load. But the script is downloaded during html parsing.
I don't have idea about how delayLoadTime is supposed to behave when used in combination with defer.salmon-plastic-31303
11/11/2022, 11:28 AMgentle-petabyte-80785
11/11/2022, 11:36 AMdelayLoadTime is not explained properly, I assume it is useful in cases when you want to manually load the script.
But here you don't want to go about manually loading the script, rather your goal is to optimise the page performance (correct me if I'm wrong).
So in that case, I'd simply avoid changing delayLoadTime and just use loadType defer as you have. And I think that would be all for the page optimisation you need because in case of defer browser decides the best possible time for that script to load based on the computing resources available and based on other scripts you have on your page.salmon-plastic-31303
11/11/2022, 11:39 AMsalmon-plastic-31303
11/11/2022, 11:39 AMsalmon-plastic-31303
11/11/2022, 11:39 AMsalmon-plastic-31303
11/11/2022, 11:40 AMgentle-petabyte-80785
11/11/2022, 11:42 AMsalmon-plastic-31303
11/11/2022, 11:42 AMgentle-petabyte-80785
11/11/2022, 11:42 AMgentle-petabyte-80785
11/11/2022, 11:42 AMsalmon-plastic-31303
11/11/2022, 11:43 AMgentle-petabyte-80785
11/11/2022, 11:51 AM<script defer src="..rudder-analytics.min.js" . You are using the script before even it is loaded or maybe I'm missing something.
Anyway, for now, you're fine. If you don't see any event in your RS dashboard, likely it is the #2 point I'm mentioningsalmon-plastic-31303
11/11/2022, 11:53 AMsalmon-plastic-31303
11/11/2022, 11:56 AMgentle-petabyte-80785
11/11/2022, 12:00 PMsalmon-plastic-31303
11/13/2022, 9:40 AMsalmon-plastic-31303
11/14/2022, 8:48 AMgentle-petabyte-80785
11/14/2022, 12:59 PMif I just reference the script link with defer added and comment out the gatsby config will it still work?Yes. Just comment out gatsby config and then add the reference of rudder script wherever you find it fit.
salmon-plastic-31303
11/14/2022, 1:36 PMshy-kite-21035
11/14/2022, 2:36 PMhelpful-daybreak-79835
11/16/2022, 4:43 AMdelayLoadTime seconds
Can you check that please?
If possible, can you integrate the Gatsby plugin back so we can investigate further?salmon-plastic-31303
11/16/2022, 7:05 AMsalmon-plastic-31303
11/16/2022, 7:06 AMsalmon-plastic-31303
11/16/2022, 7:07 AMhigh-zoo-17436
11/16/2022, 11:46 AMdelayLoad, delayLoadTime can you set loadType: 'defer' and let us know the result.salmon-plastic-31303
11/16/2022, 11:50 AMsalmon-plastic-31303
11/16/2022, 11:51 AMsalmon-plastic-31303
11/16/2022, 11:53 AMhigh-zoo-17436
11/16/2022, 11:54 AMsalmon-plastic-31303
11/16/2022, 11:56 AMsalmon-plastic-31303
11/16/2022, 11:57 AMhigh-zoo-17436
11/16/2022, 12:07 PMdelayLoad and delayLoadTime this script loading is delayed. So if you expanded the waterfall view you will see that is happening after the given time.salmon-plastic-31303
11/16/2022, 12:13 PMsalmon-plastic-31303
11/16/2022, 12:15 PMsalmon-plastic-31303
11/16/2022, 12:16 PMhigh-zoo-17436
11/16/2022, 12:18 PMuseNewSDK: true in the plugin options.high-zoo-17436
11/16/2022, 12:19 PMsalmon-plastic-31303
11/16/2022, 12:20 PMhigh-zoo-17436
11/16/2022, 12:21 PMsalmon-plastic-31303
11/16/2022, 12:21 PMhelpful-daybreak-79835
11/16/2022, 12:21 PMhelpful-daybreak-79835
11/16/2022, 12:22 PMuseNewSDK next to loadTypesalmon-plastic-31303
11/16/2022, 12:23 PMsalmon-plastic-31303
11/16/2022, 12:23 PMhelpful-daybreak-79835
11/16/2022, 12:23 PMhelpful-daybreak-79835
11/16/2022, 12:25 PMsetPostBodyComponents support in onRenderBody API but not sure, if that'll serve your purpose. Anyway, we'll check it out.salmon-plastic-31303
11/16/2022, 12:34 PMsalmon-plastic-31303
11/16/2022, 12:36 PMsalmon-plastic-31303
11/16/2022, 12:37 PMsalmon-plastic-31303
11/16/2022, 12:37 PMsalmon-plastic-31303
11/16/2022, 12:37 PMhelpful-daybreak-79835
11/16/2022, 12:39 PMStrangely defer loads the script earlier than async.Can you try this set up on a simpler site version to investigate further?
helpful-daybreak-79835
11/16/2022, 12:39 PM<script async > for the rendering. Maybe the browser is interpreting it as an empty string. Which browser are you checking this on?salmon-plastic-31303
11/16/2022, 12:40 PMsalmon-plastic-31303
11/16/2022, 12:41 PMsalmon-plastic-31303
11/16/2022, 12:41 PMhelpful-daybreak-79835
11/16/2022, 12:43 PMsalmon-plastic-31303
11/16/2022, 12:44 PMsalmon-plastic-31303
11/16/2022, 12:45 PMsalmon-plastic-31303
11/16/2022, 12:46 PMhelpful-daybreak-79835
11/16/2022, 1:09 PMasync is equivalent to async=true. Same with defer. It defaults to true.salmon-plastic-31303
11/16/2022, 1:12 PMsalmon-plastic-31303
11/16/2022, 1:12 PMhelpful-daybreak-79835
11/16/2022, 1:38 PMhelpful-daybreak-79835
11/16/2022, 3:32 PMasync keyword is enough to change the script load type i.e, async, async=true, async="", etc. are all equivalent in behavior.helpful-daybreak-79835
11/16/2022, 3:33 PMsalmon-plastic-31303
11/16/2022, 7:16 PMhelpful-daybreak-79835
11/17/2022, 4:28 AMsalmon-plastic-31303
11/17/2022, 7:41 AMhelpful-daybreak-79835
11/17/2022, 10:58 AMsalmon-plastic-31303
11/17/2022, 5:18 PMsalmon-plastic-31303
11/17/2022, 5:19 PMhelpful-daybreak-79835
11/22/2022, 3:16 PMhigh-zoo-17436
12/14/2022, 2:09 PMsalmon-plastic-31303
12/14/2022, 2:22 PMhigh-zoo-17436
12/14/2022, 2:23 PMsalmon-plastic-31303
12/14/2022, 2:29 PMhigh-zoo-17436
12/14/2022, 2:31 PMhigh-zoo-17436
12/14/2022, 2:32 PMsalmon-plastic-31303
12/14/2022, 2:34 PMhigh-zoo-17436
12/14/2022, 2:35 PMsalmon-plastic-31303
12/14/2022, 2:46 PMsalmon-plastic-31303
12/14/2022, 2:46 PMsalmon-plastic-31303
12/14/2022, 2:50 PMsalmon-plastic-31303
12/14/2022, 2:51 PMsalmon-plastic-31303
12/14/2022, 2:59 PMsalmon-plastic-31303
12/14/2022, 2:59 PMsalmon-plastic-31303
12/14/2022, 3:07 PMsalmon-plastic-31303
12/14/2022, 3:14 PMsalmon-plastic-31303
12/14/2022, 3:14 PMhigh-zoo-17436
12/14/2022, 3:16 PMhelpful-daybreak-79835
12/14/2022, 3:17 PMhigh-zoo-17436
12/14/2022, 3:17 PMyarn add gatsby-plugin-rudderstack@2.0.0high-zoo-17436
12/14/2022, 3:19 PMlatest flag that is also finehigh-zoo-17436
12/14/2022, 3:19 PMsalmon-plastic-31303
12/14/2022, 3:21 PMhelpful-daybreak-79835
12/14/2022, 3:43 PMloadType is still respected now. It's just that the SDK script tag gets added to the page after the wait time specified in the delayLoadTime with appropriate load type set.gentle-petabyte-80785
12/14/2022, 3:50 PMsalmon-plastic-31303
12/14/2022, 8:33 PM