Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[📖] Integration guide for Wordpress #646

Open
SpyrosBou opened this issue Dec 2, 2024 · 5 comments
Open

[📖] Integration guide for Wordpress #646

SpyrosBou opened this issue Dec 2, 2024 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@SpyrosBou
Copy link

Suggestion

Hey all,

I've been trying to set partytown up for a wordpress website and realised there's no documentation on how that should work. I've been coming across a bunch of issues as a result. Would be really nice if there was a WP section so I could know I'm on the right path - so I thought I'd drop a suggestion.

Thanks!

@SpyrosBou SpyrosBou added the documentation Improvements or additions to documentation label Dec 2, 2024
@gioboa
Copy link
Member

gioboa commented Dec 2, 2024

Hi, I have no experience with WP, I'm sorry. You can drop your questions here.
If you find a way to use it, feel free to drop a PR.

@SpyrosBou
Copy link
Author

SpyrosBou commented Jan 2, 2025

Hey there,

Happy New Year and thanks for the reply. I'll type out what I've done so far and the questions I'm having.

So I went with the basic html-type integration. Essentially I added the code to the header.php file of my custom theme. Here's what that currently looks like:

<script>
	partytown = {
		forward: ["dataLayer.push"],
		debug: true,
		logCalls: true,  // This probably isn't right
	};
</script>

<script>/* Partytown 0.11.0 - MIT QwikDev */
	**Pasted entire contents of partytown.js** 
</script>

Then did <script type="text/partytown"> to all the relevant 3rd party scripts, in this case being analytics.js, gtm and a cookie manager script.

The partytown files are located in the root directory of my website as below:
image
image

I'm currently getting a successful call to partytown-sw.js and the thread worker seems registered and active:
image
image

But as you can see I'm also getting a 404 for the .html file. Another issue is I'm not getting verbose logging in my console tab at all. I am not sure exactly how to enable the logging to begin with - I couldn't find a clear explanation in the docs for this.

I am not certain whether I'm loading the partytown script correctly either. I've tried pasting the partytown-snippet.js code instead, same end result.

If anyone can offer any help or point out any mistakes I'm making I'd really appreciate it.

@gioboa
Copy link
Member

gioboa commented Jan 3, 2025

Thanks for the update.
From this issue #629 I can see that @westonruter is trying to do a similar thing. 👀

@SpyrosBou
Copy link
Author

I think the issue in that thread is a bit more advanced than what I'm trying to do here. I'm trying to set up a basic integration, #629 is dealing with the woocommerce plugin. That said I think @westonruter has successfully dealt with the basic integration before moving onto connecting it with WooCommerce so perhaps he could help me out

@westonruter
Copy link
Contributor

I've put together a basic integration in the Web Worker Offloading plugin. Using that plugin, you can easily opt-in a script to be offloaded to Partytown via this PHP code:

wp_script_add_data( $script_handle, 'worker', true );

The plugin also has built-in integrations with a few popular plugins for offloading gtag to Partytown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants